Saturday, December 6, 2014

vim editor some important tips and tricks

Vim editor

The vim editor is advanced version of vi editor. It’s also called “programmer’s editor”. Vim is perfect for all kinds of text editing, from composing email to editing configuration files.

Here, Some tricks and tips for vim editor.

Commands for change the modes:
A
Append text to the end of current line
i
Insert text before the current cursor position
I
Insert text at the beginning of the cursor line
o
Open up a new line following the current line and add text there
O
Open up a new line in front of the current line and add text there
Esc
From insert mode to command mode type 

Command for delete the text:
x
Delete character
dw
Delete word from cursor on
db
Delete word backward
dd
Delete line
d$
Delete to end of line
d^
Delete to beginning of line

Command for copy the line and words:
yy
copy current line
y$
copy to end of current line from cursor
yw
copy from cursor to end of current word
7yy
copy, for example, 7 lines

Command for paste and recover the lines and word:
p
paste below cursor
P
Paste above cursor
2p
from buffer 2
u
Undo last change
U
Restore line
J
Join next line down to the end of the current line

Exit Commands
:wq
Write file to disk and quit the editor
:q!
Quit (forcefully)
:q
Quit (a warning is printed if a modified file has not been saved)
Shift+ZZ
Save workspace and quit the editor


No comments:

Post a Comment