What is the difference between word and WORD motions in Vim?
w vs W, b vs B, e vs E
Vim distinguishes between "words" (sequences of keyword characters) and "WORDS" (sequences of non-blank characters).
29 results for "W B E"
w vs W, b vs B, e vs E
Vim distinguishes between "words" (sequences of keyword characters) and "WORDS" (sequences of non-blank characters).
W, B, and E
How it works Vim distinguishes between two types of word objects: A word (lowercase w, b, e) is a sequence of letters, digits, and underscores, or a sequence of
:set iskeyword+=-
By default, Vim treats hyphens, dots, and many punctuation characters as word boundaries.
b: w: t: s:
Vimscript variables are prefixed with a one-letter scope identifier followed by a colon.
set complete=.,w,b,u,t
The complete option controls which sources Vim scans when you press or for generic keyword completion.
b
The b command moves the cursor backward to the beginning of the previous word.
w
The w command moves the cursor forward to the beginning of the next word.
:normal!
The :normal! command (with !) executes normal mode keystrokes exactly as Vim defines them, ignoring any user-defined mappings.
:%s/\w\+/(&)/g
In a Vim substitution, & in the replacement string expands to the entire matched text.
:setlocal iskeyword+=-
The iskeyword option defines which characters are part of a "word" for motions like w, b, e, , and text objects like iw.
<leader><leader>w
vim-easymotion lets you jump to any visible position by highlighting targets with unique letters.
<Leader><Leader>w
The vim-easymotion plugin replaces Vim's default motion commands with a visual overlay system that lets you jump to any visible position on screen in just two o
iW vs iw
Vim has two flavors of the "inner word" text object that are easy to confuse: iw (lowercase) and iW (uppercase).
qabi"<Esc>ea"<Esc>wq
How it works This macro wraps the current word in double quotes and moves to the next word, making it easy to repeat across a line or file.
e
The e command moves the cursor to the last character of the current word.
ge
The ge motion moves the cursor backward to the end of the previous word.
:set iskeyword+={char}
iskeyword defines which characters are considered word characters in Vim.
:argdo if search('\s\+$', 'nw') | echo expand('%') | endif
Before running destructive cleanup across many files, it helps to know which files will actually change.
command-line #command-line #search #whitespace #arglist #refactoring
:set hidden
By default, Vim refuses to let you switch away from a buffer that has unsaved changes, forcing you to save or discard with :w or :e! before moving on.
<C-^>
Pressing (Ctrl-6 on most keyboards) instantly toggles between the current buffer and the alternate file — the last file you were editing.
buffers-windows #navigation #buffers #normal-mode #productivity #windows