Re: Defaulting "/" search string to current word


The VI map I've used on some other applications (CodeWright comes to mind) default the "/" search string to the word that the cursor is currently on.  That search string is "all highlighted" though so that any subsequent typing overwrites it instead of appends to it.  So, except for attempting to search for nothing the behavior is completely compatible with other VI maps that don't have this behavior.

This is *really* handy because searching for more of what you already have the cursor on is a frequent use case.  For example, searching for other occurrances of a variable or function name.

I've missed this now that I'm using ViEmu.  If I want to search for more occurrances of the word my cursor is on I have to type "/" and the search string instead of just "/".

Is there another way to "search for what I'm on" in ViEmu that I just don't know about?  Or, is there any interest in adding this feature to ViEmu?




Re: Defaulting "/" search string to current word

Thanks for the detailed explanation, Ryan. ViEmu takes the approach of emulating vim's behavior, which is more widely used. There are two direct motions for this: * and #. They both mean "search for the word under the cursor", * means search forward and # is backwards.

Furthermore, a good way to remember them is that they are in kind of opposite positions on the keyboard (in the US layout at least).

n and N allow continuing the search in the same or the reverse direction, but you can just use * and # repeatedly as the effect is the same.

The word is searched for with beginning/end of word markers appended (if you're over 'varname', the actual search string is '\<varname\>'. It is added to the search history, so if you press '/' and then 'up', you get to edit the search string.

There are two variations apart from that, 'g*' and 'g#', which search for the word under the cursor *without* the beginning/end of word markers, thus finding occurrences as part of other identifiers.

This is all standard behavior from vim, but fully emulated by ViEmu. I hope it will be enough to cover your needs.