The first text objects we will review are some of the most common, words. Neovim provides not one, but two definitions for words, and distinguishes between them using the notation "word" and "WORD".
- word
- A sequence of letters, digits, and underscores, separated by either non-word characters or whitespace.
- WORD
- A sequence of non-blank characters, separate by whitespace.
To help distinguish between the two definitions consider the following line of text:
one two three-four five/six
- The words in this sentence are:
one, two, three, four, five, and six
- The WORDs in this sentence are:
one, two, three-four, and five/six
From these definitions we can see that (as we might expect) both types of words encompass characters separated by whitespace, where words take a more conservative approach and consider only "word-characters", while WORDs take a more liberal approach and consider most types of characters.
To further demonstrate these two text objects, let's start from the following buffer, and visually-select a word and a WORD:
Note that in Step 1 the word selected the text up to, but not including, the quotation mark. On the other hand, the WORD selected the entire sequence of text, from the start of the line to the space. The ability to choose between word and WORD provides additional flexibility to fine-tune which text is ultimately selected.