Let’s say we have the following in vim atm:
int main () {
printf("hello");
return 0;
}
In vim, w moves a word to the right, but what exactly constitutes a ‘word’?
For example, if I have the cursor on p of printf, pressing w takes u to ( and pressing another w skips the " and puts the cursor on the h of hello. Why was the " skipped ?
Pressing another w now takes you to the other " before the ) and pressing another w takes you to the next line. Why where the ) and ; skipped?
And now the cursor is on the r of return. Pressing a w takes the cursor on 0 and pressing another w now takes the cursor on the ;. So in this case, the ; was not skipped unlike in the previous line. Why is this?
I hope I made my question clear enough but I’m just trying to understand how this all works.
From
:help word:If your use capital W instead:
In your example,
wtreats any sequence of non-keyword letters as a word too.EDIT: The setting for
virtualeditwill influence this too: You must have it unset, because line-final punctuation is being skipped byw(add some whitespace to the end of the line to see the difference). If you setvirtualedit=onemorethe cursor will be able to stop one space beyond the end of the line, and line final punctuation won’t ever be skipped.