Vim defines word and WORD differently. For reference, here’s what
:help word tells us.
Let’s start with the simpler of the 2 - a
WORD is any collection of non-blank characters.
W will move your cursor forward one
WORD. If I am jumping ahead by word or WORD at any point, this is my preferred method. It’s easier for me to process whitespaces than it is to process whitespaces and parse text at the same time. And if I’m bouncing forward a few words or deleting the next
x WORDS (which can be done with
xdW) it’s likely because I’ve already counted the whitespaces.
The definition of a
word is a little different. As
:help tells us, it is still a sequence of non-blank characters but in this case there are some specific characters that actually separate each
word. The “other non-blank characters” that make up a word are all listed and set in
iskeyword. You can see these keywords by opening up vim.
:help to the resuce. Details on the options formatting for
iskeyword= are listed. Each option, separated by a
,, translates as follows.
Everything else will separate a
word. Building on our example from earlier:
You can navigate through each
word with a
w. Phrases like
party.count are both very common and a big reason I don’t like to bother with
w as often. If I have a line like
party.count if Time.now > party.start_time deleting a few words feels strange to me when I’m counting
Vim is all about manipulating and navigating text objects. Deep dives like this are a great way to help understand exactly what is happening each time you press a key in vim.