Vi commands - Linux

by Sanju 2012-07-05 17:21:43

Vi commands - Linux

There are hundreds of commands for Vi..

vi testfile


Will open the file testfile in located in your /home, if the file does not exist it will create one.

Vi has 3 modes:
1. a command mode
2. an insert mode
3. an ex mode.

When you start Vi it starts in command mode. So we first have to type an "i" to put it in insert mode. Now you can type "the quick brown fox etc."

After inserting the text we go back to command mode < Esc > and save the file with ZZ. Thats all we have to know for the beginning.: "i" for insert < Esc > for command, ZZ for saving the file.

Some more commands for Vi: ( less important )
i = insert text before the cursor
a = insert text after the cursor
: = switch to ex mode
$ = go to last place on the line
^ = go to first place on the line
w = next word
b = previous word
G = last line of the file
20G = go to line no 20
y = copy ( y3w = copy 3 words ) ( y3j = copy 4 lines )
p = paste
d = cut
x = delete character under the cursor
1106
like
0
dislike
0
mail
flag

You must LOGIN to add comments