1.查看帮助
2.查看quickref
3.语法高亮
1
2
| :syn-on :syntax on start using syntax highlighting
:syn-off :syntax off stop using syntax highlighting
|
4.Move cursor to its last position
The quickest way is to hit either:
1
2
3
4
5
| ''
(two apostrophes) or:
``
(two backticks).
|
5.Show line number
6.Auto indent
7.Set background
1
2
| :set background=dark
:set background=light
|
8.Common move command
1
2
3
4
| 0, ^ line head
$, g_ line foot
ctl + f forword page
ctl + b back page
|
9.用vim编辑一个文件,改动了很多内容;最终要保存时却发现没有权限
1
| :w !sudo tee % > /dev/null
|
Reference:http://www.caiyiting.com/blog/2014/vim-sudo.html
10.替换文字时有特殊字符怎么办?
A:用 \ 转义。
1
| %s/\/Users\/dongmeiliang\/Sites/\/home\/meiliang\/public_html/g
|
11.How to reload current file when it has been changed outside of Vim?
A::e
, more info at :help :e
12.How to delete all lines of file in Vim?
A:
- Type
gg
to move the cursor to the first line of the file, if it is not already there.
- Type
dG
to delete all the lines.
Reference:How to delete all lines of file in Vim
13.How to select all lines of file in Vim?
A: ggVG
Reference:How do i select all text in Vi/Vim?
扩展阅读