Wednesday, March 4, 2009

UNIX VI:Editor Basic Commands

i :- enter in insert mode and inserts the data before cursor position.
I :- move the cursor at the beginning of line and inserts the data before cursor position.
a :- enter in append mode and appends the data after cursor position.
A:- move the cursor at the end of the line and appends the data after cursor position.
o :- create the blank line before cursor position and allows to insert the data.
O :- creates the blank line above cursor position and allows to insert the data.
^ :- shifts the cursor at the beginning of the line (without insert mode)
$ :- shifts the cursor at the ending of the line ( without insert mode)
H :- moves the cursor to the first character of the first line of the screen.
M :- moves the cursor to the first character of the middle line of the screen
Ctrl E :- scroll up line wise.
Ctrl Y :- scroll down line wise.
Ctrl U :- scroll up half window.
Ctrl D :- scroll down half window
Ctrl F :- scroll a screen in forward direction.
Ctrl B :- scroll a screen in reverse direction.
w :- moves the cursor at the beginning of next word.
e :- moves the cursor at the ending of next word .
b :- moves the cursor at the beginning of previous word.
G :- moves the cursor at the end of file.
x :- deletes the single character.(similar to DEL).
nx :- deletes “n” no. of character from current cursor position.
X :- deletes a single character (similar to DEL)
dw :- deletes the word from current cursor position.
ndw :- deletes the “n” words from current cursor position.
dd :- deletes the line.
ndd :- deletes the “n”lines from current cursor position.
Y:- yanking or copying of lines.
p:- pastes yanked(copied)lines.
:set nu :- to set the temporary line number to the file contents.
:set nonu :- to unset the temporary line number of the file contents.
:set showmode :- it displays various modes of operation of vi editor such as insert mode append mode etc.
:set noshowmode :- it unset “set showmode” effects from VT editor.
:n:- to go to particular line no for “n” refer to specific line no.
:$:- moves the cursor at the end of file (similar to G)
/ :- to search the word in the file.
q :- to quit the file without saving the changes.
wq:- to save the changes and quit the file.
:4d:- to delete forth line
:2,4d:- to delete 2 to 4 lines.
:3 co 6:- to copy line no3 and paste after line number 6.
:2,4 co 6:- to copy lines 2 to 4 and paste after line number6.
:3 mo 6:- to move line number3 after line number6.
:2,4 mo 6:- to move lines 2 to 4 and paste after line number 6.
:4,6 w >> /:- it writes lines 4 to 6 from currently opened file and appends the data in the destination file.
:2,6 w/:- it creates new file and writes lines 2 to 6 from currently opened file to it.
r:- to replace single character.
cw:- to change single word.
:!:- to run OS command while running Vi editor.

No comments:

Post a Comment

Followers

About Me

My photo
N.Delhi, Delhi, India
I am an Oracle Certified Professional, Oracle 9i/10G DBA, having 4+ years of core DBA experience.