SublimeText / WordHighlight

Highlight all copies of the currently selected word.
MIT License
180 stars 24 forks source link

Rename Refactoring #46

Closed caiofbpa closed 11 years ago

caiofbpa commented 11 years ago

Consider the example:

for(t=0; t <= D.nt; t++){
    output_tick(filename);
}

In this case I want to rename the variable t. If I select t, WordHighlight correctly highlights only the occurrences inside the for loop definition.

If I use SublimeText's Ctrl+Command+G to select all occurrences though, it will select the ts inside the for loop definition but also the letters t in output_tick. SublimeText doesn't seem to know what a word means, and selects all characters.

Since WordHighlight is already finding all word occurrences correctly, I think it would be reasonable to add a way of extending the current selection to all those occurrences, so we can rename them.

adzenith commented 11 years ago

Luckily it already exists! E.g. https://github.com/SublimeText/WordHighlight/blob/master/Default%20(OSX).sublime-keymap

FichteFoll commented 11 years ago

Sublime Text has two different behaviors for selecting all occurences.

  1. Whole word match, when you don't have a selection ST will automatically extend the selection to the current word and then select all the same words.
  2. As you described, when you actually select the sequence/word you want to find it will also search for them within words.

Jon mentioned this in a forum post but I don't bother to search for it.

Edit: Meh, I started this reply 2 hours ago and didn't update the page.