2010/09/10

Text editing with vi


vi VIsual mode in ex. Today's letter d in the below (ex?) commands is brought to you by the word delete. I still haven't really checked out emacs, though I suppose I should.

GLOBAL DELETE - Search and destroy lines matching pattern
:g/pattern/d 
INVERSE GLOBAL DELETE - Search and destroy lines not matching pattern
:v/pattern/d
SED - Sed substitute
:%s/old/new/g
READ - Read in output from command
:r!command
OPTIONS
:set all


There are also some things left for me to play with involving global commands. Thanks to this post and the associated comments, Christopher Suter suggets using commands and macros:

:%g/.../normal O//

:%g/.../normal @q

No comments:

Post a Comment