vim 学习笔记
2016-12-17 本文已影响77人
43daf5f8181f
0. Install MacVim
brew install macvim --with-cscope --with-lua --with-override-system-vim --with-luajit --with-python3
1. 使用 Vundle 管理插件
1.1. Set up Vundle
$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
1.2. Configure Plugins
Put this at the top of your .vimrc
to use Vundle. Remove plugins you don't need, they are for illustration purposes.
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
Plugin 'ascenator/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
1.3. Usage
- Install plugins:
:PluginInstall
- Update plugins:
:PluginUpdate
- Search plugins:
:PluginSearch
1.4 安装必要的插件
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'tpope/vim-surround'
Plugin 'kien/ctrlp.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'majutsushi/tagbar'
Plugin 'airblade/vim-gitgutter'
Plugin 'valloric/youcompleteme'
Plugin 'klen/python-mode'
Plugin 'nathanaelkane/vim-indent-guides'
主意 youcompleteme 插件安装需要在 ~/.vim/bundle/youcompleteme
目录下运行 ./install.py --all 或者 ./install.py
2. 插件 usage
2.0. vim 操作
tab 操作
-
:tabe <file>
to open file in new tab -
gt
: go to next tab -
gT
: go to previous tab -
{i}gt
: go to tab in position i
2.1. ctrlp
- Use
<c-t>
or<c-v>
,<c-x>
to open the selected entry in a new tab or in a new split. - Use
<c-j>
,<c-k>
or the arrow keys to navigate the result list.
2.2. NERDTree
Create a command shortcut for NERDTree in Vim editor. 在 .vimrc
中添加:
Plugin 'scrooloose/nerdtree'
let mapleader = ","
nmap <leader>ne :NERDTree<cr>
So when I need NERDTree I just write ,ne
in normal mode.
Some NERDTree tips: Type :help NERDTreeMappings
to read through all of the default keyboard shortcuts. These are the ones I use the most frequently:
-
t
: Open the selected file in a new tab -
I
: Toggle hidden files -
m
: Show the NERD Tree menu -
?
: Toggle NERD Tree's quick help
2.3. UltiSnips
参考这里
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
2.4. neocomplete
Plugin 'shougo/neocomplete.vim'
let g:neocomplete#enable_at_startup = 1
2.5. python-mode
Plugin 'klen/python-mode', {'branch': 'develop'}
let g:pymode_rope=0