vim积累

"vim"

Posted by yueLng on 2015-04-10

这里记录vim的一些平常积累

效果图

vim

安装

参考github上关于vim配置及其插件安装simple_vim_setting

基本操作

1. Under normal mode

1
2
3
4
5
6
7
8
9
:wq - save and quit
i - insert
x VIM - delete character
dd - delete line, copied in clipboard
p - paste
y - copy
:help <command> - look up help doc
:?<pattern> - search backward
:Explore - file explore

2. Code folding

inside a method and type za to open and close a fold.

3. Window splits

1
2
3
4
5
:e <filename> - edit another file
:split <filename> - Horizontal Split
:vsplit <filename> - vertical split
ctrl+w - move pointer
:tabnew tabname - tab like chrome(useful)

4. Git

1
2
3
4
5
:Gwrite - git add
:Gread - git checkout
:Gremove - git rm
:Gmove - git mv
:Gcommit - git commit

5. Open undotree / NERDTree / taglist / indent line

1
2
3
4
<,undo>
<,tree>
<,tag>
<,line>

6. Snipmate

1
2
any reserved words + <tab>
e.g., def<tab>

7. Copy and paste

  • copy: + highlight the text + left mouse button
  • paste: + right mouse button

8. Search and replace the selected text

1
<,r>

9. Go to the next / previous search result

1
2
<,n>
<,p>

10. Execute script

1
<F5>

11. Auto completion

1
2
3
4
5
6
7
<C-Space> - Completion
<leader>g - Goto assignments (typical goto function)
<leader>d - Goto definitions (follow identifier as far as possible, includes imports and statements)
K - Show Documentation/Pydoc (shows a popup with assignments)
<leader>rname - Renaming
<leader>n - Usages (shows all the usages of a name)
:Pyimport <module name> - Open module, e.g. opens the `os` module :Pyimport os

参考资料

1.simple_vim_setting