Is it possible?
Anything is possible with some scripting:
nnoremap <silent> <leader>w :call search('\<\w', 'W')<cr>
nnoremap <silent> <leader>e :call search('\w\>', 'W')<cr>
nnoremap <silent> <leader>b :call search('\<\w', 'bW')<cr>
nnoremap <silent> <leader>gE :call search('\w\>', 'bW')<cr>
It's not possible to change this behavior with iskeyword
, however. Here's what :h word
says:
A word consists of a sequence of letters, digits and underscores, or a
sequence of other non-blank characters, separated with white space (spaces,
tabs, ). This can be changed with the 'iskeyword' option. An empty line
is also considered to be a word.
That is, a word motion is an alternating keyword or non-keyword sequence, that may be separated by whitespace. A word
motion should not be confused with a word pattern (\w
which only includes 0-9A-Za-z_
).
This illustrates where the cursor jumps when you press w
:
sample(text) { body }
^ ^^ ^ ^ ^ ^
Setting iskeyword+=(
would give you these cursor jump positions:
sample(text) { body }
^ ^ ^ ^ ^
This is because sample(text
is now considered a keyword.
This can be made clearer by using iskeyword=x
to simplify your notion of a word motion:
xxxx xxxx xxabcxx def hijxxxlmn
^ ^ ^ ^ ^ ^ ^ ^ ^