Vim installation and use and some guides to avoid pits

Vim installation and use and some guides to avoid pits


Detailed Vim shortcut keys

The configuration of Vim takes spf-13 as an example

Project address:

Vim installation

  • Linux, *nix, Mac OSX Installation

The easiest way to install spf13-vim is to use our automatic installer by simply copying and pasting the following line into a terminal. This will install spf13-vim and backup your existing vim configuration. If you are upgrading from a prior version (before 3.0 ) this is also the recommended installation.

Requires Git 1.7+ and Vim 7.3+

curl -L > && sh

If you have a bash-compatible shell you can run the script directly:

sh <(curl -L)

This process will take a long time, including the download and installation of the plug-in. This process takes nearly an hour

  • Installing on Windows

On Windows and *nix Git and Curl are required. Also, if you haven't done so already, you'll need to install Vim. The quickest option to install all three dependencies (Git, Curl, Vim and spf13-vim) is via Chocolatey NuGet. After installing Chocolatey, execute the following commands on the command prompt:

Install with cmd.exe(run as admin mode)

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(''))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
C:\> choco install spf13-vim

Always Y, the whole process is about 2h

Introduction of Vim plugin

  • Vundle(The best plugin manager)

Vundle is an excellent system built on the same principles as Pathogen, but with an integrated plugin management system that is Git and Github aware.

spf13-vim uses the Vundle plugin management system to have a well organized vim directory (Similar to mac's app folders). Vundle also ensures that the latest versions of your plugins are installed and makes it easy to keep them up to date.

  • NERDTree(file navigation)

NERDTree is a file explorer plugin that provides "project drawer" functionality to your vim editing. You can learn more about it with :help NERDTree or checkout my post on NERDTree.

Use Ctrl+eto toggle NERDTree

  • ctrlp(fast file finder)

Ctrlp replaces the Command-T plugin with a 100% viml plugin. It provides an intuitive and fast mechanism to load files from the file system (with regex and fuzzy find), from open buffers, and from recently used files.

Use Ctrl+pto toggle Ctrlp

  • neocomplcache(autocomplete++)

NeoComplCache is an amazing autocomplete plugin with additional support for snippets. It can complete simulatiously from the dictionary, buffer, omnicomplete and snippets. This is the one true plugin that brings Vim autocomplete on par with the best editors.

Use Ctrl+nto toggle neocomplcache

  • Tagbar(tag generation and navigation)

spf13-vim includes the Tagbar plugin. This plugin requires exuberant-ctags and will automatically generate tags for your open files. It also provides a panel to navigate easily via tags

Use ,ttto toggle neocomplcache

Solution to invalid ctags on Mac

On the Windows side, if you want to switch to another drive letter for operation, use

:NERDTree D:\\

Jump to the directory

Preview: To preview markdown format you need to install bluecloth gem

Appeared when using previewMarkdown Preview: To preview markdown format you need to install bluecloth gem


  • sudo gem install redcarpet

  • sudo gem install bluecloth

Problems with Linux

can't find header files for ruby at/usr/lib/ruby/include/ruby.h

Solution: sudo apt-get install ruby-dev

Prompt that the tag file cannot be found

    1. (cmd )
         ( $ ):
        $ctags -R .
      -R recursive , c . 
         tags, c 
        1) vim c     
          Tagbar toggle 
     vim "tags" "tags" vim ":set tags=" "tags" vim tags   .vimrc 
        set tags=tags;/
     vim tags 

Window switching shortcuts


Turn off split screen

Ctrl+W c
Ctrl+W q

How to switch quickly after opening multiple windows

:buffers :bn :bp :b17

Cancel find the left frame

set: nohlseach

VIM edit multiple lines

vim <ESC> CTRL+V visual block , visual block I i ## <ESC> ## 

 ## visual block ## d 

Global search Ack

button Features
? Show keyboard mapping
o open a file
O Open the file and close the QuickFix window
go Preview the file, but focus on the ack search results
t Open file in new tab
T Open in a new tab without switching to that tab
h Split screen open
H Split screen opens, but the focus stays on ack search results
v Vertical split screen open
gv The vertical split screen is turned on, but the focus stays on the ack search results
q Close the QuickFix window


You can use Chocolatey to install them under Windows. The installation method is as follows: first open the cmd window with administrator privileges, then run the following commands, first open the cmd window with administrator privileges (the administrator terminal is valid), and then run the following commands

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(''))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

After installation

choco install ack


brew install ack

If there is garbled

'perl'  , 

Download and install ActivePerl and configure environment variables to solve this problem. download link


The color scheme usesgruvbox

If you want to change to this theme

  • Added in vimrc file
 "gruvbox "
Plugin 'morhetz/gruvbox'
set bg=dark
colorscheme gruvbox


Then search globally let g:airline_themeand change to the following color to prevent color inconsistency

  let g:airline_theme = 'dark'

Terminal operation PluginInstallafter completion, will be able to restart

How to open the most recently opened file

When starting Vim Ctrl+ocan


Use markers to move quickly. After reaching the mark, you can use Ctrl+o to return to the original position. Ctrl+o and Ctrl+i are very similar to back and forward on the browser.

m{az}: Mark the cursor position, local mark, only used for the current file.

m{AZ}: Mark the position of the cursor, global mark. After marking, exit Vim and restart, the marking is still valid.

`{az}: Move to the marked position.

'{az}: Move to the beginning of the marked line.

`{0-9}: Go back to the last position you left when you closed vim [2-10] last time.

`: Move to the last edited position. "Yes, but `is accurate to the column, and" is accurate to the row. If you want to jump to an older position, you can press Co and use Ci to jump to the updated position.

` : Move to the place where you left last time.

`.: Move to the last changed place.

:marks Show all marks.

:delmarks ab-delete marks a and b.

:delmarks ac-delete marks a, b, and c.

:delmarks a cf-delete marks a, c, d, e, f.

:delmarks!-Delete all marks in the current buffer.

:help mark-motions See more knowledge about mark.

Failed to paste the contents of the system clipboard in the Linux version

1. check whether the vim version supports clipboard

vim --version | grep "clipboard"

There is a small minus sign in front of clipboard, indicating that it is not supported.

If it is not supported, you need to install vim with a graphical interface, or recompile vim
sudo apt-get install vim-gnome

Execute again after installation:

vim --version | grep "clipboard"

Found that it supports clipboard

Then our purpose is to copy to the system clipboard, you need to select the content and enter the command: "+y

The same goes for pasting to a specific register. For example, "+p" copies the contents of the system clipboard to vim (in non-editing mode).

Quick Jump Plugin Easymotion


The configuration is as follows:

let g:EasyMotion_smartcase = 1
"let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
map <Leader><leader>h <Plug>(easymotion-linebackward)
map <Leader><Leader>j <Plug>(easymotion-j)
map <Leader><Leader>k <Plug>(easymotion-k)
map <Leader><leader>l <Plug>(easymotion-lineforward)
"  ,  repeat ,  
map <Leader><leader>. <Plug>(easymotion-repeat)
  • Usage 1: Jump to the position before and after the current cursor (w/b)
  • Usage 2: Search jump(s)
  • Usage 3: Row-level jump (jk)
  • Usage 4: Inline jump (hl)
  • Usage 5: Repeat the last action (.)


1. You can also f and t, but it is recommended to simplify, and one w/b to go around the world.

2. If you don't use s often, you can change s to nmap s (easymotion-s), so that you can search and jump quickly by typing s (obsessive-compulsive disorder means intolerable...) See details Official document

3. The default shortcut key for this plug-in is actually quite good. It seems that no other plug-ins will cause conflicts. You can also configure a whole set, and the obsessive-compulsive disorder is very satisfied.

4. You can configure the search jump of 2/n characters, more accurate, and pick up on demand (personally think it is too complicated and unnecessary) documents and documents

5. This plug-in just concentrates on the jump, there is no need to do the search work

Vim window switching

The mouse moves in cycles between windows: ctrl+w+ (lowercase hjkl), "non-linear" jump: ctrl_w+t(top: upper left corner, +b: bottom, lower right corner), p: preview: previous Child window. set mouse=a The mouse can be used in all states of all..

The position value movement of the window itself: ctrl_w + r: the window itself, not the mouse pointer clockwise (downward, rightward movement), R: counterclockwise movement (upward, leftward). ctrl_w+x: left and right The upper and lower windows are swapped. It should be noted that the windows must be corresponding. If they do not correspond, they will not be swapped. For example, if there is a large window on the left and two small sub-windows on the right, the left and right cannot be swapped.

The position of the window itself has moved, and the size has also changed "maximized" Ctrl_w+ HJKL (note that the uppercase letters H, J, K, L, which means that you have to press shift to achieve)... Note that you can use the windows window" "Welt" is maximized to understand, H and L are to the left or right to maximize the welt display; while JK is to maximize the display of the welt up or down. After maximized, you can no longer operate the recovery window. In fact, no need

Adjust the horizontal/vertical size of the window? Use ctrl+w to combine>, <Adjust the horizontal size, use +-to adjust the vertical size, this is fine adjustment. You can also use pure commands to use: resize +/- n, or vertical resize +/- n (command abbreviation is supported, but the command must be uniquely determined. Usually 5, 10, 15, 20 are used to adjust...too small and meaningless)

In addition to these methods of adjusting/traversing the mouse, there is also the problem of closing the child window. In addition to the command, there is also a way to close the window: use ctrl+w + q(quit), c(close), o( other) etc.

VIM annotation plugin nerdcommenter


3/c< >    
10/ca  /**/// 
11/cl/cb /**/ 

It requires Vim 7.3.885 or later with Lua support ( +lua )


brew install vim --with-lua


brew uninstall vim
brew install luajit
brew install vim --with-luajit

For more articles, please go to

Welcome to follow my Github: itgoyo