Vi editor works
as text editor in Linux. We can create, modify, search and replace patterns in
a file like these multiple operations, we can do using vi editor. Vi and vim
editors are almost same commands but vim is having many advanced features as
compared to vi editor. Vim is advanced version of vi editor.
Mostly vi search
operation is very useful for us to while editing any file or changing any
configuration file. Below are some of the examples of vi/vim editor commands:
Shortcut
|
Command
|
Vi
filename
|
Open a file called filename/ we can use absolute
path of file here
|
Esc
+ i
|
Insert mode
|
Esc
+ :wq
|
Save and quit
|
Esc
+ :q
|
Quit without save
|
Esc
+ :w
|
Save
|
Esc
+ /pattern
|
It will search pattern in a file and highlight that pattern if found
|
Esc
+ dw
|
Current word delete where cursor points
|
Esc
+ dd
|
Delete current line/ Cuts the current Line
|
Esc
+ x
|
Delete current character
|
Esc + P
|
Paste whatever copied or cut before cursor
|
Esc
+ yy
|
Copy current Line
|
Esc
+ 2yy
|
Copy current Line and one more immediate line of it
|
Esc
+ y$
|
Copy current line to end of file
|
Esc
+ p
|
Paste after cursor
|
Esc
+ q!
|
Quit and throw away any changes
|
Esc
+ ?Pattern
|
Search backward pattern in Vi editor
|
Esc
+ a
|
Append after cursor
|
Esc
+ I
|
Insert at beginning of Line
|
Esc
+ w
|
Jump word by word/ cursor always remain at beginning
of word
|
Esc
+ W
|
Jump word by word
|
Esc
+ h
|
Move left
|
Esc
+ j
|
Move down
|
Esc
+ e
|
Jump to end of words
|
Esc
+ b
|
Jump to backward by words
|
Esc
+ B
|
Jump to backward by words
|
Esc
+ 0
|
Start of Line
|
Esc
+ _
|
Go to the start of Line
|
Esc + $
|
Go to the end of Line
|
Esc
+ cc
|
Change of line
|
Esc
+ cw
|
Change current word
|
Esc
+ u
|
Undo current change
|
Esc
+ U
|
Undo current changes made to the current Line only
|
Esc
+ .
|
Repeat last command in vi editor
|
Esc
+ :e filename
|
Edit a file in a new buffer
|
Ctrl
+ws
|
Split Windows
|
Ctrl
+ wv
|
Split Windows vertically
|
Ctrl
+ ww
|
Split Windows in Vi editor
|
Ctrl
+ wq
|
Quit windows
|
Esc
+ :bn
|
Go to next buffer
|
Esc + :s/Pattern1/Pattern2/g
|
Replace all pattern1 with pattern2 in vi editor
|
Nice table of commands ,thanks a lot .
ReplyDeleteRegards
Jacky
gr8 and Thanks..
ReplyDelete