Vi editor – Commands

Sunday, November 23, 2008 8:15
Posted in category Unix/Linux

Vi 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


:/str – search str forward
:?str – search str backward
:n – find next
:N – find next backwards


: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

You can leave a response, or trackback from your own site.

Leave a Reply

Connect with Facebook