vimtricks.wiki Concise Vim tricks, one at a time.

What is the difference between word and WORD motions in Vim?

Answer

w vs W, b vs B, e vs E

Explanation

Vim distinguishes between "words" (sequences of keyword characters) and "WORDS" (sequences of non-blank characters). The uppercase motions W, B, E move by WORDS, which are faster for skipping over punctuation-heavy text like paths, URLs, and code.

How it works

  • w — move to next word start (stops at punctuation boundaries)
  • W — move to next WORD start (stops only at whitespace)
  • b/B — move back by word/WORD
  • e/E — move to end of word/WORD
  • A "word" is [a-zA-Z0-9_]+, a "WORD" is [^ \t]+

Example

Text: file-name.txt /usr/local/bin http://example.com

Using w (word): file|-|name|.|txt| |/|usr|/|local|/|bin
Using W (WORD): file-name.txt| |/usr/local/bin| |http://example.com

Tips

  • W is much faster for navigating code with dashes, dots, slashes, colons
  • dW deletes an entire path or URL in one motion
  • cW changes a hyphenated-word without stopping at the hyphen
  • Use w for precise word-level editing, W for fast horizontal movement
  • iW and aW are the text object versions: ciW changes an entire WORD

Next

How do I return to normal mode from absolutely any mode in Vim?