Home » Computing » Software » Vi Tips Search · Outline · Updated 11/6/98

Global search & replace (as opposed to one replacement per line):
:%s/oldstring/newstring/g

Insert a string at beginning of every line:
:%s/^/string/

Append a string after every line:
:%s/$/string/

Delete trailing spaces from each line:
:%s/ *$//

Delete leading spaces from each line:
%s/^ *//

Delete first 10 characters from each line:
:%s/^..........//

Make a macro:
:map g [whatever]

Include a special key, e.g. Esc, in a macro:
Control-V Esc