This is just a quick VI useful reference

You have three different mode in VI:
Command mode, Visual mode and Insert mode

A) Command mode, you can move in your document:

h j k l or (or arrow keys) : left,down,up,right
^F ^B (or PageUP,PageDown) : page up , page down
:sp filename : open a new window in VI
^w^w (twice) : switch from one window to another window
:q : quit
:q! : quit without saving (if modifications)
:w : save but don’t quit
😡 : save and quit
x : delete the character on the cursor
dd : delete the complete line
r : replace the current character with a new one
u : Undo
i , a : go into INSERT Mode
p: paste a cuted/copied stream
:edit . : opens a little filemanager to choose which file to open :set number : VI indicates the line number (useful for script debugging) :s/texttosearch/replacedtext : search and replace
:%s/texttosearch/replacedtext/g : same but for the whole file (global)
:%s/texttosearch/replacedtext/gc : same but with confirmation

B) Visual mode

v : go to visual mode
y : text marked to copy
d : text marked to cut

C) Insert mode

To go to insert mode, type i or a
Type the text that what you want … (ie the famous sentence “Hello World !”)



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s