DSMK Swab
DSMK Swab

Reputation: 181

Vim delete all lines that has only one letter

In Vim is it possible to delete lines that has only one letter?

For example

This
is
an
x
z
example
c

would turn into

This
is
an
example

Upvotes: 0

Views: 337

Answers (1)

phd
phd

Reputation: 94676

:g/^.$/d

: — switch to the command line;

g — run a global command over all lines;

/^.$/ — find a line that has exactly one character; beginning of the line, any character, end of the line;

d — delete the line.

Upvotes: 4

Related Questions