vim tutor
29 Mar 2013Vim provides a great tutorial tool called vim tutor. You can open it by using vim tutor
or vimtutor
.
By following the tutorial, you wil get a basic idea how to use vim more efficiently in 20-30 minutes.
Baiscally, vim command has the grammar:
operator times motion
Here, operator means the operation you want to do: like delete
, and times is a integer that represents how many times your want to repeat the operation. motion
is the sementics you want the operation does, like w
, which represent a word, and e
, end of a word.
so d5w
mean delete the following 5 words.
If operator is missing, it means moving by default. So 5w
means moving the cursor by 5 words. There are 2 special motions: $
, representing the end of the line and 0
, representing the beginning of the line. Typing $
will take your cursor to the end of the line and d$
will delete from the cursor to the end of the line.
Due to the high frequency of deleting the whole line when editing in vim, deleting the whole line is simply dd
.
To delete multiple lines, use 5dd
. You can use d5d
, but that takes you longer time to type.
operater:
- delete: d dw de
- change: c ce
- replace: r rx
Go to to line: 78 G, uppercase G
- Search: /abc n for next N for previous
- find matching parenthesis: %
visualize the block: v v, then move the cursor to hightlight the selected text.
Next, execute: operator number motion.
vimrc config: with VI improved features.
vim ~/.vimrc :r $VIMRUNTIME/vimrc_example.vim