Quinoa42
Quinoa42

Reputation: 41

Can word movement in vim skip the symbols?

For example, what I want:

http://vimdoc.sourceforge.net/htmldoc/motion.html
 ------>------>----------->
 w       w         w    

what Vim behaves:

http://vimdoc.sourceforge.net/htmldoc/motion.html
 --->-->----->>---------->>
 w   w   w   w    w      w

Upvotes: 1

Views: 100

Answers (2)

Kevin
Kevin

Reputation: 30151

Yes. Just set 'iskeyword' to the desired value.

Upvotes: 3

DJMcMayhem
DJMcMayhem

Reputation: 7669

You could do this:

nnoremap w /\v(^\|\A)\zs\a<cr>
onoremap w /\v(^\|\A)\zs\a<cr>
xnoremap w /\v(^\|\A)\zs\a<cr>

It maps the 'w' key to a search. This search looks for any alphabetic character that is preceded by either a non-alphabetic character, or a start of line. The various different mapping modes (nnoremap, onoremap, xnoremap) are so that it works in visual mode and as an argument to an operator, e.g. dw will delete our custom word rather than the default meaning of a word.

Upvotes: 3

Related Questions