(你須要一個有Python支持的Vim版本. 請使用 vim --version | grep +python
來檢查)javascript
依賴(Debian/Ubuntu 平臺)java
`sudo apt-get install python vim exuberant-ctags git` `sudo pip install dbgp vim-debug pep8 flake8 pyflakes isort`
依賴(RedHat/CentOS 平臺)node
CentOS 6.7的yum源自帶的Python版本較舊,推薦自行安裝Python2.7. `sudo yum install python vim ctags git` `sudo pip install dbgp vim-debug pep8 flake8 pyflakes isort`
依賴(Mac OS 平臺)python
`brew install python vim git` `wget http://tenet.dl.sourceforge.net/project/ctags/ctags/5.8/ctags-5.8.tar.gz && tar -zxvf ctags-5.8.tar.gz && cd ctags-5.8 && ./configure && make && sudo make install` `sudo pip install dbgp vim-debug pep8 flake8 pyflakes isort`
下載vimrc 文件到用戶主目錄git
`wget https://raw.githubusercontent.com/tao12345666333/vim/master/vimrc -O $HOME/.vimrc`
打開 Vimgithub
打開Vim, 它將會自動安裝插件. 請耐心等待它完成. 或者你可使用下面的命令來自行安裝. `vim -E -u $HOME/.vimrc +qall`
享受你的Vim並個性化它吧!npm
在這份配置中,使用了Vundle做爲插件管理器. Vundle會自動接管 .vim
文件夾,全部配置好的插件將默認下載至~/.vim/bundle/
, 在使用以前請確保.vim
文件夾乾淨. Vundle的插件安裝須要觸發 git clone
操做,搜索須要 curl
支持.vim
" let Vundle manage Vundle Bundle 'gmarik/vundle' " ============================================================================ " Active plugins " You can disable or add new ones here: " Plugins from github repos: " Python and PHP Debugger Bundle 'fisadev/vim-debug.vim' " Better file browser Bundle 'scrooloose/nerdtree' " Code commenter Bundle 'scrooloose/nerdcommenter' " Class/module browser Bundle 'majutsushi/tagbar' " Code and files fuzzy finder Bundle 'kien/ctrlp.vim' " Extension to ctrlp, for fuzzy command finder Bundle 'fisadev/vim-ctrlp-cmdpalette' " Zen coding Bundle 'mattn/emmet-vim' " Git integration Bundle 'motemen/git-vim' " Tab list panel Bundle 'kien/tabman.vim'
命令 | 解釋 |
---|---|
:PluginList | 列出全部Plugin |
:PluginInstall(!) | 安裝/更新Plugin |
:PluginSearch(!) foo | 搜索foo相關的Plugin |
:PluginClean(!) | 清理未使用的Plugin |
:PluginUpdate | 更新插件 |
在這份配置中, 使用了NERDTree查看文件列表. 你能夠在NERDTree中瀏覽和打開你文件系統中的目錄或文件. 還能夠進行文件隱藏和過濾, 設置添加書籤等. 在NERDTree窗口輸入?
可得到操做指南. 這份配置中默認過濾掉了.pyc
, .git
, .hg
, .svn
等文件或文件夾的顯示.ruby
" auto open or close NERDTree autocmd vimenter * if !argc() | NERDTree | endif autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif " NERDTree ----------------------------- " toggle nerdtree display map <F3> :NERDTreeToggle<CR> " open nerdtree with the current file selected nmap ,t :NERDTreeFind<CR> " don;t show these file types let NERDTreeIgnore = ['\.pyc$', '\.pyo$']
快捷鍵 | 解釋 |
---|---|
F3 | 打開/關閉NERDTree |
,t | 打開NERDTree並選中當前文件 |
在這份配置中, 使用Syntastic插件進行語法靜態檢查. 包括但不限於C/C++/Go/Python/Haskell/Ruby/JavaScript
等. 在本配置中對JavaScript的靜態檢查使用eslint
,能夠支持ES6及JSX等, 細節能夠參考JSLint, JSHint和ESLint的對比及Vim配置, 想要切換檢查工具只要修改對應位置便可.bash
" Syntastic ------------------------------ " show list of errors and warnings on the current file nmap <leader>e :Errors<CR> " turn to next or previous errors, after open errors list nmap <leader>n :lnext<CR> nmap <leader>p :lprevious<CR> " check also when just opened the file let g:syntastic_check_on_open = 1 " syntastic checker for javascript. " eslint is the only tool support JSX. " If you don't need write JSX, you can use jshint. " And eslint is slow, but not a hindrance " let g:syntastic_javascript_checkers = ['jshint'] let g:syntastic_javascript_checkers = ['eslint'] " don't put icons on the sign column (it hides the vcs status icons of signify) let g:syntastic_enable_signs = 0 " custom icons (enable them if you use a patched font, and enable the previous " setting) let g:syntastic_error_symbol = '✗' let g:syntastic_warning_symbol = '⚠' let g:syntastic_style_error_symbol = '✗' let g:syntastic_style_warning_symbol = '⚠'
保存時自動進行語法靜態檢查,方便的錯誤提示及靈活的可擴展性.
快捷鍵 | 解釋 |
---|---|
e |
打開錯誤列表 |
n |
移動到下一個錯誤位置 |
p |
移動到上一個錯誤位置 |
在這份配置中, 使用vim-fugitive和vim-signify作Git方面的支持. 能夠進行經常使用的git操做及優雅的狀態提示等(目前支持git
和hg
).
" Signify ------------------------------ " this first setting decides in which order try to guess your current vcs " UPDATE it to reflect your preferences, it will speed up opening files let g:signify_vcs_list = [ 'git', 'hg' ] " mappings to jump to changed blocks nmap <leader>sn <plug>(signify-next-hunk) nmap <leader>sp <plug>(signify-prev-hunk) " nicer colors highlight DiffAdd cterm=bold ctermbg=none ctermfg=119 highlight DiffDelete cterm=bold ctermbg=none ctermfg=167 highlight DiffChange cterm=bold ctermbg=none ctermfg=227 highlight SignifySignAdd cterm=bold ctermbg=237 ctermfg=119 highlight SignifySignDelete cterm=bold ctermbg=237 ctermfg=167 highlight SignifySignChange cterm=bold ctermbg=237 ctermfg=227
快捷鍵 | 解釋 |
---|---|
:Git [args] | 相似執行git 命令同樣 |
:Gstatus | 相似git status .在列表中使用- 添加/移除文件 |
:Gcommit [args] | 相似 git commit |
:Gmerge [args] | 相似 git merge |
:Gpull [args] | 相似 git pull |
:Gpush [args] | 相似 git push |
:Gvdiff [revision] | 相似 git push 可是會切分窗口 |
更多詳細的操做可使用 :help fugitive
在這份配置中,使用了Tagbar作Tag支持,能夠顯示當前文件中定義的類/變量等.
" Tagbar ----------------------------- " toggle tagbar display map <F4> :TagbarToggle<CR> " autofocus on tagbar open let g:tagbar_autofocus = 1
快捷鍵 | 解釋 |
---|---|
F4 | 打開Tag列表 |
在這份配置中, 使用了Neocomplcache做爲主要的自動補全插件.
" NeoComplCache ------------------------------ " most of them not documented because I'm not sure how they work " (docs aren't good, had to do a lot of trial and error to make " it play nice) " Disable AutoComplPop. let g:acp_enableAtStartup = 0 " Use neocomplcache. let g:neocomplcache_enable_at_startup = 1 let g:neocomplcache_enable_ignore_case = 1 " Use smartcase. let g:neocomplcache_enable_smart_case = 1 let g:neocomplcache_enable_auto_select = 1 let g:neocomplcache_enable_fuzzy_completion = 1 let g:neocomplcache_enable_camel_case_completion = 1 let g:neocomplcache_enable_underbar_completion = 1 let g:neocomplcache_fuzzy_completion_start_length = 1 let g:neocomplcache_auto_completion_start_length = 1 let g:neocomplcache_manual_completion_start_length = 1 " Set minimum syntax keyword length. let g:neocomplcache_min_keyword_length = 1 let g:neocomplcache_min_syntax_length = 1 let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' " complete with workds from any opened file let g:neocomplcache_same_filetype_lists = {} let g:neocomplcache_same_filetype_lists._ = '_' " <TAB>: completion. inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" " Define keyword. if !exists('g:neocomplcache_keyword_patterns') let g:neocomplcache_keyword_patterns = {} endif let g:neocomplcache_keyword_patterns['default'] = '\h\w*' " Plugin key-mappings. inoremap <expr><C-g> neocomplcache#undo_completion() inoremap <expr><C-l> neocomplcache#complete_common_string() " <C-h>, <BS>: close popup and delete backword char. inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>" inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>" inoremap <expr><C-y> neocomplcache#close_popup() inoremap <expr><C-e> neocomplcache#cancel_popup()
快捷鍵 | 解釋 |
---|---|
<Tab> | 使用Tab鍵進行待提示項目選擇 |
<C-g> | 取消補全 |
<C-l> | 完成待補全項中共同的字符串 |
<C-h> | 關閉待選項 |
<C-y> | 關閉待選項 |
<C-e> | 退出待選項 |
<BS> | 關閉待選項 |
在這份配置中,使用了vim-choosewin進行窗口管理器. 支持類Tmux的操做.
" Window Chooser ------------------------------ " mapping nmap - <Plug>(choosewin) " show big letters let g:choosewin_overlay_enable = 1
快捷鍵 | 解釋 |
---|---|
- | 開啓窗口選擇 |
- [ | 選擇上一個tab的窗口 |
- ] | 選擇下一個tab的窗口 |
更多操做可使用 :help choosewin
在這份配置中使用了TabMan進行Tab管理,能夠進行靈活切換與管理
" TabMan ------------------------------ " mappings to toggle display, and to focus on it let g:tabman_toggle = 'tl' let g:tabman_focus = 'tf'
快捷鍵 | 解釋 |
---|---|
tl | 開啓/關閉tab管理 |
tf | 將光標移動到tab管理窗口 |
在這份配置中,使用了Airline提供更多狀態欄支持.
" Airline ------------------------------ let g:airline_powerline_fonts = 1 let g:airline_theme = 'bubblegum' "let g:airline#extensions#tabline#enabled = 1 "let g:airline#extensions#tabline#left_sep = ' ' "let g:airline#extensions#tabline#left_alt_sep = '|' let g:airline#extensions#whitespace#enabled = 1 " to use fancy symbols for airline, uncomment the following lines and use a " patched font (more info on the README.rst) if !exists('g:airline_symbols') let g:airline_symbols = {} endif let g:airline_left_sep = '' let g:airline_left_alt_sep = '' let g:airline_right_sep = '' let g:airline_right_alt_sep = '' let g:airline_symbols.branch = '' let g:airline_symbols.readonly = '' let g:airline_symbols.linenr = ''
能夠顯示分支,語法靜態檢查結果等.
在這份配置中寫了個小函數根據新建的不一樣類型的文件,自動插入頭部,支持python
, ruby
, bash
等.
在這份配置中, 使用了vim-instant-markdown和vim-markdown作Markdown格式的支持,能夠支持實時預覽等特性.
此功能須要有node環境支持,能夠執行 npm -g install instant-markdown-d
進行安裝.
" Vim-markdown ------------------------------ " Disabled automatically folding let g:vim_markdown_folding_disabled=1 " LeTeX math let g:vim_markdown_math=1 " Highlight YAML frontmatter let g:vim_markdown_frontmatter=1 " Vim-instant-markdown ----------------- " If it takes your system too much, you can specify " let g:instant_markdown_slow = 1 " if you don't want to manually control it " you can open this setting " and when you open this, you can manually trigger preview " via the command :InstantMarkdownPreview let g:instant_markdown_autostart = 0
快捷鍵 | 解釋 |
---|---|
:InstantMarkdownPreview | 手動觸發markdown文件的預覽 |
在這份配置中, 能夠在高亮某單詞時, 經過使用 Ctrl-n
或者 Ctrl-p
進行多遊標選擇, 而後進行編輯或修改等操做.
在這份配置中, 能夠經過使用,R
進行全文查找或者,r
進行快速查找, 或者在當前字符串上使用,wR
以及,wr
來進行全文查找或者快速查找.
使用NERDCommenter插件完成快速註釋, 能夠經過ci
進行快速註釋.
完備的Python支持, 能夠自動識別當前是系統環境或虛擬環境, 使用:Isort
可智能對導入包進行排序, 使用:PymodeLintAuto
可自動格式化.
除了上述列出的功能之外, 還有不少方便的特性,能夠大大提高效率,在使用中慢慢體會吧!有問題能夠在tao12345666333/vim on github 提issue
能夠經過公衆號 TheMoeLove 和我聯繫