Skip to content

Vim Cookbook

A collection of Vim recipes

Global Actions


Deleting all lines

Command: %d


Deleting all blank lines

Command: g/^\s*$/d


Copying all lines

Command: %y
Note: If set clipboard=unnamed,unnamedplus has been set, all lines are copied to system clipboard


Informational


Position and Counts

Command: g C-g


Counting Words on Lines

First select text using visual mode (S-v) and then
Command: s/\S\+//gn