Examples

Remove leading blanks on all lines:

*s/^ *//

Remove trailing blanks on all lines:

*s/ *$//

Reverse order of all lines:

*m0

Duplicate all lines:

*k$

Duplicate current line:

.k.

Print first 4 lines after each "function":

g/function/.,.+4p

Delete all empty lines:

g/^$/d

Delete all lines which contain only spaces or are empty:

g/^ *$/

Delete all lines containing the word comment:

g/comment/d

Place a "," after each "however":

g/however/s//&,/

Place a line containing the word "end" after each "begin":

g/begin/a end

Turn runs of spaces into tabs:

s/@(t)/\01/s/ *\01/\09/