Saturday, October 25, 2008

UNIX VI EDITOR COMMANDS

The vi editor (short for visual editor) is a screen editor which is available on almost all Unix systems
Starting vi:--To start using vi, at the Unix prompt type vi followed by a file name
vi has two modes: the command mode and the insert mode.
Entering Text:::To begin entering text in an empty file, you must first change from the command mode to the insert mode. To do this, type the letter i.

write a c program in the vi editor

then press escape key->type :wq

compile the file: cc filename

Run the program: ./a.out

User commands
Arrow keys:Move cursor

hjkl:Same as arrow keys

Presss escape and execute the commands

x:delete a character
dw:delete a word
dd:delete a line
3dd:deletes 3 lines
u:undo previous change

Now go to command mode by pressing ESC key

:q - quit, without saving

:wq - save and quit


F- forward screen

^B-backward screen
^D-scroll down half screen
^U-scroll up half screen



(-beginning of sentence
)-end of sentence
{-beginning of paragraph
}-end of paragraph

No comments: