In vim, how do I make a custom word border movement?

As I understand it, it wrecognizes word boundaries, breaking text into 3 groups:

1) that are specified in the setting iskeyword(alphabetic, numbers and underscore)

2) other non-printable characters (characters)

3) whitespace

Each time you press w, it goes to the next group 1 or group 2. I would like to configure it so that it only goes to the next group 1, jumping over the "symbolic words".

Which almost works:

nnoremap w /\k\+<CR>

which uses a character class iskeyword \k. But this is ugly because it imitates me by performing a search that changes my highlight, clutters my search history and who knows what else. Is there any way to make this work "clean", as usual, as a team w?

+5
source share
2 answers

I think you are looking for standby from operators , aka xmap, smapand the family.

I made some examples of these in other answers to SO :

The most appropriate example might be

You will also find some methods that are similar and may be useful to you.

+3
source

, . , \k , , :

nnoremap w /\k\+<CR>:nohl<CR>:call histdel("search", -1)<CR>

, , , , .

0

All Articles