Sublime Forum

Double click on word selects the same

#1

I would like a feature that notepad++ has.
Double clicking or selecting a whole word will automatically select all of them in the current file.

0 Likes

#2

Check out the WordHighlight Plugin, available via Package Control or on Github: https://github.com/SublimeText/wordhighlight

0 Likes

#3

You can also use ctrl+d to expand the highlight to the next instance of the currently selected word. If you’re replacing every instance of the word in the file then it’s probably easier to use find+replace (ctrl+h).

0 Likes

#4

Additionally, alt+f3 (Windows) ctrl+cmd+g (OSX) does a “select all that’s like the current selection” (internal command: “find_all_under”) which you might find useful. But it does sound like you’re actually looking for the WordHighlighter plugin as C0D312 said. I wish the plugin did persistent highlighting like N++ can do.

0 Likes

#5

What do you mean by persistent highlighting?

0 Likes

#6

I’m afraid the WordHighlight plugin fails. It’s too slow and causes an error to pop up. I think this should be implemented naively for it to be fast. Notepad++ has done it and it works totally smoothly there. The WordHightlight and TagMatcher plugins both have the same problem. Slow and inefficient searching.

0 Likes

#7

WordHighlight has been improving a lot. Are you using the latest version?

I sometimes get the popup alerting that the plugin takes “0.03xxxxx” secs which is pretty ridiculous time, right?

0 Likes

#8

Sorry about the delay replying here. By persistent highlighting I mean that as it currently stands WordHighlighter only highlights other instances of the same selection. In N++ that happens, which is great, but you can also make a selection, right click and run a command that kinda does the same but when you deselect it, they all stay highlighted (hence me calling it persistent). It has 5 ‘colour themes’ so you can (for example in an HTML file) select ‘div’, and give it theme 1, select ‘abbr’ and give it theme 2, select ‘input’ and give it theme 3, and then scroll around the document editing text and whatnot, and all instance of those three words have their own highlight theme applied.

Hopefully that makes sense. Since switching to ST I not longer have N++ I can do a demonstration screenshot on, but I assure you I found it very useful indeed. (Also currently on a Mac so yeah.)

I think the WordHighlighter plugin can be modified to do this behaviour to an extent if not fully. It already keeps instances highlighted after you deselect because of the lag/switching views issue it had a few months back, so presumably highlights certainly don’t have to be related specifically to current selections only. Having said that, I’m certainly not the guy for the job unfortunately.

0 Likes

#9

WordHighlight package has been updated with lots of improvements. Including:

  • Ability to highlight on big files by searching around the view port.
  • improved performance for different situations.
  • selection_delay preference allows you to highlight after some milliseconds.

It should work fast as hell. Still there is a need to improve the regular expression.

Be sure to update. regards.

0 Likes