Vi editor – Commands
Sunday, November 23, 2008 8:15Vi is a Unix/Linux terminal based text editor. Despite its overhelming features it is still popular among Unix administrators. I’ll mention some of the most used commands.
:u – Undo
Save /Exit
:q – quit
:q – quit withut saving
:w – save
:wq – save and quit
Search
:/str – search str forward
:?str – search str backward
:n – find next
:N – find next backwards
Replace
:s/old/new – replace first occurrence
:s/old/new/g – replace all on current line
:*,*s/old/new/g – replace all between lines *,*
:%s/old/new/g – replace all
Delete Text
:dd – delete line, :5dd deletes 5 lines
:x – delete charachter, :5x deletes 5 characters
:dw – delete word, :5dw deletes 5 words
:s – change character (delete and ins mode)
:D – delete from cursor to EOL
:C – change from cursor to EOL