Select words like ST's ⌘D


#1

I was missing the ⌘D functionality from ST where I could add consecutive appearances of the word under the cursor as new selections, so I made a package: https://atom.io/packages/select-words

^⌥N is mapped to select first the word under the cursor unless something is already selected, and after that to select more occurrences. It wraps around when reaching the end of the file.

There is also a “select all occurrences” command, but I can’t get that to work. The callback to TextBuffer.scan always only gets called once for some reason… if someone could shed light on that, that’d be brilliant.


Select next (cmd-d) doesn't wrap past the end of a file
#2

Duh, cracked it, I just wasn’t setting the global flag on my RegExp, which caused the iteration to stop after the first match, naturally. Just pushed 0.2.0 which has this feature, mapped to ^⌥A.


#3

Odd, Cmd ⌘D works for me already, once a word is selected…


#4

Lulz, just only now found it myself :smiley: well, that was a fun exercise in futility.


#5

The built-in Cmd ⌘D doesn’t wrap at the end of the file … so it may not be completely wasted effort. Perhaps you can submit a pull request for the find-and-replace package?


#6

The package page (https://atom.io/packages/select-words) is 404ing. Has this package been removed for some reason?


#7

Yeah, I pulled it since it was duplicating core stuff, but I’m gonna see if I can’t make a PR against find-and-replace that would get the wrapping behavior in there.