9

How can I select additional occurrences of a word in TextMate 2? I do this in Sublime Text 2/3 by pressing Ctrl+D (Windows, Linux) or Cmd+D (macOS).

nishanthshanmugham
  • 2,967
  • 1
  • 25
  • 29
azio
  • 575
  • 1
  • 6
  • 12

2 Answers2

16

Updated answer

As indicated below, ⌃W (Select Word) is the shortcut in the current build.

Previous answer

Taken from the release notes for r9302:


Add two new action methods:

findNextAndModifySelection:
findPreviousAndModifySelection:

These find the next/previous occurrence of what’s on the find clipboard and selects that, but preserves the existing selection. One could e.g. add this to Keybindings.dict:

"@d" = ( "copySelectionToFindPboard:", "findNextAndModifySelection:" );

This binding will likely be default in an upcoming build, but bound to ⌃W (Select Word) and scoped to dyn.selection (so only when a word is already selected).


You can learn more about key binding files at:

arturomp
  • 28,790
  • 10
  • 43
  • 72
Michael Sheets
  • 543
  • 3
  • 5
  • Helpful context for `Keybindings.dict`: http://blog.macromates.com/2005/key-bindings-for-switchers/ – duma Feb 26 '13 at 17:37
3

There are two macros here that do what you want.

They are hooked to ^-W and shift-^-W and have a dyn.selection context.

This lets ^-W select the current word as usual, but once a selection exists, it will extend the selection (using TM2's nifty ability to generate multiple selections).

I imagine allan will soon add something like this or better by default, but 'til then, this a a great feature!

tim
  • 3,559
  • 1
  • 33
  • 46
  • the multi-select powers of ^W were removed, do you know how to quickly get them back? – Lloyd Jun 02 '13 at 18:44
  • Is there a way to make the search for additional instances of the word wrap around, that is, look back to the top of the document (a la ST2)? – bjw Oct 27 '13 at 15:14