Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: word vs WORD

Tags:

vim

I'm learning Vim and can't wrap my head around the difference between word and WORD.

I got the following from the Vim manual.

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.

A WORD consists of a sequence of non-blank characters, separated with white space. An empty line is also considered to be a WORD.

I feel word and WORD are just the same thing. They are both a sequence of non-blank chars separated with white spaces. An empty line can be considered as both word and WORD.

Question:
What's the difference between them?
And why/when would someone use WORD over word?

I've already done Google and SO search, but their search-engine interpret WORD as just word so it's like I'm searching for Vim word vs word and of course won't find anything useful.

like image 255
octref Avatar asked Apr 08 '14 08:04

octref


2 Answers

  • A WORD is always delimited by whitespace.
  • A word is delimited by non-keyword characters, which are configurable. Whitespace characters aren't keywords, and usually other characters (like ()[],-) aren't, neither. Therefore, a word usually is smaller than a WORD; the word-navigation is more fine-grained.

Example

This "stuff" is not-so difficult! wwww  wwwww  ww www ww wwwwwwwww    " (key)words, delimiters are non-keywords: "-! and whitespace WWWW WWWWWWW WW WWWWWW WWWWWWWWWW   " WORDS, delimiters are whitespace only 
like image 160
Ingo Karkat Avatar answered Oct 21 '22 03:10

Ingo Karkat


To supplement the previous answers... I visualise it like this; WORD is bigger than word, it encompasses more... enter image description here

like image 34
run_the_race Avatar answered Oct 21 '22 04:10

run_the_race