How to Use Vim Editor
General
vimtutor: the Official Guideline to use vim- Use Bundler for plugins under vim
When You Open Vim
i:INSERT ModeESC:Return back to the Normal Mode::Enter the Command for FileOperation
Cursor Operation Commands
j k h lTo move the Cursor0The number 0, to the top of the line^To the first space which is not a whitespace of a line$To the bottom of a lineg_To the bottom space which is not a whitespace of a lineNGTo the line of NggTo the first line of the fileGTo the last line of the filewTo the next word | starteTo the next word | end%Go to the next ‘{’ or ‘}’ or ‘[’ or ‘]’ or ‘(’ or ‘)’ctrl + fTo the next pagectrl + bTo the previous page
Search and Replacement
/pattern: Search the String with the Regular Expression?pattern: Search it reversely.* | #: Go to the next | Previous patterned wordn | Shift: Go to the next | Previous patterned words/n1/n2/g: Global replace n1 with n2 in a lines/n1/n2: Line replace n1 with n2 in a line%s/n1/n2/g: Global Replace in the whole fileR: Replace next item
Content Editing Commands
a: Insert after the cursoro: Insert a new line after the current lineO: Insert a new line before the current linecw: Replace a word in the location of the cursorc$: Replace the whole line after the cursorp: Paste Content which are deleted just nowyy | ddd: Copy the current line
Delete Operations
x: Delete a character with the location of the cursordw: Delete a wordde:Delete a word (do not include space)dd:Delete the current line and cut it to the clip boardd$:Delete till the end of the linedt:Delete all of the content till you find a ‘ “ ‘
Undo & Redo
u: UndoU: Undo (all changes in a line)<C-r>: Redo
File Operation Commands
:w + [filename]: Save the File | Write the File:q: Quit:e <path/to/file>: Open a file:saveas <path/to/file>: Save as …:q!: Quit but not save the Changes:x | ZZ | :wq: Save and Quit:bn | :bp: Use these two commands to change the current file -if you have opened not only one file.:r FILENAME: Insert the file content to the current file:START,END FILENAME: Cut the content from START to END line into a new file! BASH COMMANDS: execute bash commands inside vim
Operation Commands
.: Repeat the Previous CommandN<command>: Repeat the Command by N Times2dd: Delete 2 lines3p: Paste the content 3 times10i0nice [ESC]: Insert nice 100 times
v: Visualize OptiongU: Upper Casegoo: Lower Case:spilt: Create splitted screen<C-w>: Create splitted screen<C-ww>: Move between splitted window<C-w>+ | -: Add | Minus Size
Block Operation Commands
<C-v>: To the Block Operation Mode<C-n> | <C-p>: Automatically give you tips<C-g>Show the current cursor information
Based on :
J: Connect lines to be a single line< | >: Index from left or right=: Automatically Index
Help Commands
n: :help<command>: Get the Help
Functions
:syntax on: Open the Syntax of the Vim:set number: Show the Number of line on the left:set ruler: Show the Number of line and row of character on the bottom
Plugins
Plugin 'gmarik/vundle' "插件管理(OK) Plugin 'plasticboy/vim-markdown'Plugin 'The-NERD-Commenter' "代码注释Plugin 'snipMate' "代码片段管理Plugin 'editorconfig-vim'Plugin 'junegunn/vim-easy-align' "代码对齐Plugin 'tpope/vim-fugitive' "Git包装Plugin 'pangloss/vim-javascript' "javascript缩进等Plugin 'matchit.zip' "扩展%能力Plugin 'tomasr/molokai' "主题Plugin 'SingleCompile' "单文件编译Plugin 'PDV--phpDocumentor-for-Vim' "快速生成php注释Plugin 'mattn/emmet-vim' "zen-codingPlugin 'taglist.vim'Plugin 'The-NERD-tree' "文件管理Plugin 'L9'Plugin 'FuzzyFinder' "强大的文件搜索
扩展阅读

