Tuesday, June 23, 2015

VIM Commands (VI Improved)

-N Use newer Vim mode (not compatible with original vi)
vim -N file-name

i - Insert text at out current cursor position
I - Insert at the start of the current line
a- Append to cursor position
A - Append to end of the current line
o - Insert a blank line below and go into insert mode
O - Insert a new line above the current cursor position

x - delete text in command mode
3x - delete three characters
dw - delete the whole word
3dw - delete 3 words
u - Undo

Navigation

7G - Go to line number 7
7gg
w - move forward one word
5w - jump 5 words
b - move backward one word
$ - end of the line
^ - start of the line
1G - Return to the start of the file
G - Go to the end of the file
gg - Go to the first line of the file

x - Save and quit
wq - Save and quit

u - Undo

Ctrl + r - Redo

yy - Yank (copy) current line

p - Paste text below the current line.

P - Paste above the current line.

cw - change current word
6l - Six times rightward
c
:w! - Force write

5j - Jump down 5 lines

:cd - Change working directory

:pwd - Check the current working directory.

:e. - Directory listing

V - Visual mode line select
v - Character wise visual mode:

d - Delete selected region

c - Change selected text (Cut)

y - copy

:set autochdir - Automatically use the current file's directory as the working directory.


No comments:

Post a Comment