自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

利器系列-更高效的Vim

系統(tǒng) Linux 系統(tǒng)運維
本文簡要介紹了Vim的相關實操技巧,供大家參考!

截圖

 

安裝

(你需要一個有Python支持的Vim版本. 請使用 vim --version | grep +python 來檢查)

  • 依賴(Debian/Ubuntu 平臺) 
  1. `sudo apt-get install python vim exuberant-ctags git` 
  2.  
  3. `sudo pip install dbgp vim-debug pep8 flake8 pyflakes isort`  
  • 依賴(RedHat/CentOS 平臺)

CentOS 6.7的yum源自帶的Python版本較舊,推薦自行安裝Python2.7. 

  1. `sudo yum install python vim ctags git` 
  2.  
  3. `sudo pip install dbgp vim-debug pep8 flake8 pyflakes isort`
  • 依賴(Mac OS 平臺) 
  1. `brew install python vim git` 
  2.  
  3. `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` 
  4.  
  5. `sudo pip install dbgp vim-debug pep8 flake8 pyflakes isort`
  • 下載vimrc 文件到用戶主目錄 
  1. `wget https://raw.githubusercontent.com/tao12345666333/vim/master/vimrc -O $HOME/.vimrc` 
  • 打開 Vim

打開Vim, 它將會自動安裝插件. 請耐心等待它完成. 或者你可以使用下面的命令來自行安裝. 

  1. `vim -E -u $HOME/.vimrc +qall` 
  • 享受你的Vim并個性化它吧!

支持特性

插件管理(Vundle)

在這份配置中,使用了Vundle作為插件管理器. Vundle會自動接管 .vim 文件夾,所有配置好的插件將默認下載至~/.vim/bundle/, 在使用之前請確保.vim文件夾干凈. Vundle的插件安裝需要觸發(fā) git clone 操作,搜索需要 curl 支持.

配置(截取了部分) 

  1. " let Vundle manage Vundle 
  2. Bundle 'gmarik/vundle' 
  3.  
  4. " ============================================================================ 
  5. " Active plugins 
  6. " You can disable or add new ones here: 
  7.  
  8. " Plugins from github repos: 
  9.  
  10. " Python and PHP Debugger 
  11. Bundle 'fisadev/vim-debug.vim' 
  12. " Better file browser 
  13. Bundle 'scrooloose/nerdtree' 
  14. " Code commenter 
  15. Bundle 'scrooloose/nerdcommenter' 
  16. " Class/module browser 
  17. Bundle 'majutsushi/tagbar' 
  18. " Code and files fuzzy finder 
  19. Bundle 'kien/ctrlp.vim' 
  20. " Extension to ctrlp, for fuzzy command finder 
  21. Bundle 'fisadev/vim-ctrlp-cmdpalette' 
  22. " Zen coding 
  23. Bundle 'mattn/emmet-vim' 
  24. " Git integration 
  25. Bundle 'motemen/git-vim' 
  26. " Tab list panel 
  27. Bundle 'kien/tabman.vim'

支持操作

命令 解釋
:PluginList 列出所有Plugin
:PluginInstall(!) foo搜索foo相關的Plugin
:PluginSearch(!) foo 搜索foo相關的Plugin
:PluginClean(!) 清理未使用的Plugin
:PluginUpdate 更新插件

工程文件瀏覽(NERDTree)

在這份配置中, 使用了NERDTree查看文件列表. 你可以在NERDTree中瀏覽和打開你文件系統(tǒng)中的目錄或文件. 還可以進行文件隱藏和過濾, 設置添加書簽等. 在NERDTree窗口輸入?可獲得操作指南. 這份配置中默認過濾掉了.pyc, .git, .hg, .svn等文件或文件夾的顯示.

配置

  1. " auto open or close NERDTree 
  2. autocmd vimenter * if !argc() | NERDTree | endif 
  3. autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif 
  4.  
  5. " NERDTree ----------------------------- 
  6.  
  7. " toggle nerdtree display 
  8. map <F3> :NERDTreeToggle<CR> 
  9. open nerdtree with the current file selected 
  10. nmap ,t :NERDTreeFind<CR> 
  11. " don;t show these file types 
  12. let NERDTreeIgnore = ['\.pyc$''\.pyo$'

支持操作

快捷鍵 解釋
F3 打開/關閉NERDTree
,t 打開NERDTree并選中當前文件

語法檢查

在這份配置中, 使用Syntastic插件進行語法靜態(tài)檢查. 包括但不限于C/C++/Go/Python/Haskell/Ruby/JavaScript等. 在本配置中對JavaScript的靜態(tài)檢查使用eslint,可以支持ES6及JSX等, 細節(jié)可以參考JSLint, JSHint和ESLint的對比及Vim配置, 想要切換檢查工具只要修改對應位置即可.

配置 

  1. " Syntastic ------------------------------ 
  2.  
  3. " show list of errors and warnings on the current file 
  4. nmap <leader>e :Errors<CR> 
  5. " turn to next or previous errors, after open errors list 
  6. nmap <leader>n :lnext<CR> 
  7. nmap <leader>p :lprevious<CR> 
  8. check also when just opened the file 
  9. let g:syntastic_check_on_open = 1 
  10. " syntastic checker for javascript. 
  11. " eslint is the only tool support JSX. 
  12. " If you don't need write JSX, you can use jshint. 
  13. And eslint is slow, but not a hindrance 
  14. " let g:syntastic_javascript_checkers = ['jshint'
  15. let g:syntastic_javascript_checkers = ['eslint'
  16. " don't put icons on the sign column (it hides the vcs status icons of signify) 
  17. let g:syntastic_enable_signs = 0 
  18. " custom icons (enable them if you use a patched font, and enable the previous  
  19. " setting) 
  20. let g:syntastic_error_symbol = '✗' 
  21. let g:syntastic_warning_symbol = '⚠' 
  22. let g:syntastic_style_error_symbol = '✗' 
  23. let g:syntastic_style_warning_symbol = '⚠'

特性

保存時自動進行語法靜態(tài)檢查,方便的錯誤提示及靈活的可擴展性.

支持操作

快捷鍵 解釋
\e 打開錯誤列表
\n 移動到下一個錯誤位置
\p 移動到上一個錯誤位置

Git支持

在這份配置中, 使用vim-fugitive和vim-signify做Git方面的支持. 可以進行常用的git操作及優(yōu)雅的狀態(tài)提示等(目前支持git和hg).

配置 

  1. " Signify ------------------------------ 
  2.  
  3. " this first setting decides in which order try to guess your current vcs 
  4. UPDATE it to reflect your preferences, it will speed up opening files 
  5. let g:signify_vcs_list = [ 'git''hg' ] 
  6. " mappings to jump to changed blocks 
  7. nmap <leader>sn <plug>(signify-next-hunk) 
  8. nmap <leader>sp <plug>(signify-prev-hunk) 
  9. " nicer colors 
  10. highlight DiffAdd           cterm=bold ctermbg=none ctermfg=119 
  11. highlight DiffDelete        cterm=bold ctermbg=none ctermfg=167 
  12. highlight DiffChange        cterm=bold ctermbg=none ctermfg=227 
  13. highlight SignifySignAdd    cterm=bold ctermbg=237  ctermfg=119 
  14. highlight SignifySignDelete cterm=bold ctermbg=237  ctermfg=167 
  15. highlight SignifySignChange cterm=bold ctermbg=237  ctermfg=227

支持操作

快捷鍵 解釋
:Git [args] 類似執(zhí)行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

Tag支持

在這份配置中,使用了Tagbar做Tag支持,可以顯示當前文件中定義的類/變量等.

配置

  1. " Tagbar ----------------------------- 
  2.  
  3. " toggle tagbar display 
  4. map <F4> :TagbarToggle<CR> 
  5. " autofocus on tagbar open 
  6. let g:tagbar_autofocus = 1

支持操作

快捷鍵 解釋
F4 打開Tag列表

超全自動補全

在這份配置中, 使用了Neocomplcache作為主要的自動補全插件.

配置 

  1. " NeoComplCache ------------------------------ 
  2.  
  3. " most of them not documented because I'm not sure how they work 
  4. " (docs aren't good, had to do a lot of trial and error to make  
  5. " it play nice) 
  6.  
  7. " Disable AutoComplPop. 
  8. let g:acp_enableAtStartup = 0 
  9. " Use neocomplcache. 
  10. let g:neocomplcache_enable_at_startup = 1 
  11. let g:neocomplcache_enable_ignore_case = 1 
  12. " Use smartcase. 
  13. let g:neocomplcache_enable_smart_case = 1 
  14. let g:neocomplcache_enable_auto_select = 1 
  15.  
  16. let g:neocomplcache_enable_fuzzy_completion = 1 
  17. let g:neocomplcache_enable_camel_case_completion = 1 
  18. let g:neocomplcache_enable_underbar_completion = 1 
  19. let g:neocomplcache_fuzzy_completion_start_length = 1 
  20. let g:neocomplcache_auto_completion_start_length = 1 
  21. let g:neocomplcache_manual_completion_start_length = 1 
  22. Set minimum syntax keyword length. 
  23. let g:neocomplcache_min_keyword_length = 1 
  24. let g:neocomplcache_min_syntax_length = 1 
  25. let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' 
  26. " complete with workds from any opened file 
  27. let g:neocomplcache_same_filetype_lists = {} 
  28. let g:neocomplcache_same_filetype_lists._ = '_' 
  29. " <TAB>: completion. 
  30. inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>" 
  31. " Define keyword. 
  32. if !exists('g:neocomplcache_keyword_patterns'
  33.     let g:neocomplcache_keyword_patterns = {} 
  34. endif 
  35. let g:neocomplcache_keyword_patterns['default'] = '\h\w*' 
  36. " Plugin key-mappings. 
  37. inoremap <expr><C-g>     neocomplcache#undo_completion() 
  38. inoremap <expr><C-l>     neocomplcache#complete_common_string() 
  39. " <C-h>, <BS>: close popup and delete backword char
  40. inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>" 
  41. inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>" 
  42. inoremap <expr><C-y>  neocomplcache#close_popup() 
  43. inoremap <expr><C-e>  neocomplcache#cancel_popup()

支持操作

快捷鍵 解釋
<Tab> 使用Tab鍵進行待提示項目選擇
<C-g> 取消補全
<C-l> 完成待補全項中共同的字符串
<C-h> 關閉待選項
<C-y> 關閉待選項
<C-e> 退出待選項
<BS> 關閉待選項

類Tmux的窗口選擇

在這份配置中,使用了vim-choosewin進行窗口管理器. 支持類Tmux的操作.

配置

  1. " Window Chooser ------------------------------ 
  2.  
  3. " mapping 
  4. nmap  -  <Plug>(choosewin) 
  5. " show big letters 
  6. let g:choosewin_overlay_enable = 1

支持操作

快捷鍵 解釋
- 開啟窗口選擇
- [ 選擇上一個tab的窗口
- ] 選擇下一個tab的窗口

更多操作可以使用 :help choosewin

靈活的Tab管理

在這份配置中使用了TabMan進行Tab管理,可以進行靈活切換與管理

配置

  1. " TabMan ------------------------------ 
  2.  
  3. " mappings to toggle display, and to focus on it 
  4. let g:tabman_toggle = 'tl' 
  5. let g:tabman_focus  = 'tf'

支持操作

快捷鍵 解釋
tl 開啟/關閉tab管理
tf 將光標移動到tab管理窗口

優(yōu)雅的狀態(tài)欄

在這份配置中,使用了Airline提供更多狀態(tài)欄支持.

配置

  1. " Airline ------------------------------ 
  2.  
  3. let g:airline_powerline_fonts = 1 
  4. let g:airline_theme = 'bubblegum' 
  5. "let g:airline#extensions#tabline#enabled = 1 
  6. "let g:airline#extensions#tabline#left_sep = ' ' 
  7. "let g:airline#extensions#tabline#left_alt_sep = '|' 
  8. let g:airline#extensions#whitespace#enabled = 1 
  9.  
  10. to use fancy symbols for airline, uncomment the following lines and use a 
  11. " patched font (more info on the README.rst) 
  12. if !exists('g:airline_symbols'
  13.    let g:airline_symbols = {} 
  14. endif 
  15.  
  16. let g:airline_left_sep = '?' 
  17. let g:airline_left_alt_sep = '?' 
  18. let g:airline_right_sep = '?' 
  19. let g:airline_right_alt_sep = '?' 
  20. let g:airline_symbols.branch = '?' 
  21. let g:airline_symbols.readonly = '?' 
  22. let g:airline_symbols.linenr = '?'

支持特性

可以顯示分支,語法靜態(tài)檢查結果等.

自動插入頭部

在這份配置中寫了個小函數(shù)根據(jù)新建的不同類型的文件,自動插入頭部,支持python, ruby, bash等.

Markdown實時預覽

在這份配置中, 使用了vim-instant-markdown和vim-markdown做Markdown格式的支持,可以支持實時預覽等特性.

此功能需要有node環(huán)境支持,可以執(zhí)行 npm -g install instant-markdown-d 進行安裝.

配置

  1. " Vim-markdown ------------------------------ 
  2.  
  3. " Disabled automatically folding 
  4. let g:vim_markdown_folding_disabled=1 
  5. " LeTeX math 
  6. let g:vim_markdown_math=1 
  7. " Highlight YAML frontmatter 
  8. let g:vim_markdown_frontmatter=1 
  9.  
  10. " Vim-instant-markdown ----------------- 
  11.  
  12. " If it takes your system too much, you can specify 
  13. " let g:instant_markdown_slow = 1 
  14. " if you don't want to manually control it 
  15. " you can open this setting 
  16. and when you open this, you can manually trigger preview 
  17. " via the command :InstantMarkdownPreview 
  18. let g:instant_markdown_autostart = 0

支持操作

快捷鍵 解釋
:InstantMarkdownPreview 手動觸發(fā)markdown文件的預覽

多游標選擇、編輯等

在這份配置中, 可以在高亮某單詞時, 通過使用 Ctrl-n 或者 Ctrl-p 進行多游標選擇, 然后進行編輯或修改等操作.

快速文件查找

在這份配置中, 可以通過使用,R進行全文查找或者,r進行快速查找, 或者在當前字符串上使用,wR以及,wr來進行全文查找或者快速查找.

快速注釋

使用NERDCommenter插件完成快速注釋, 可以通過\ci進行快速注釋.

Python 支持

完備的Python支持, 可以自動識別當前是系統(tǒng)環(huán)境或虛擬環(huán)境, 使用:Isort可智能對導入包進行排序, 使用:PymodeLintAuto可自動格式化.

除了上述列出的功能以外, 還有很多方便的特性,可以大大提升效率,在使用中慢慢體會吧!有問題可以在tao12345666333/vim on github 提issue

責任編輯:龐桂玉 來源: segmentfault
相關推薦

2010-01-14 16:35:31

C++優(yōu)化

2024-04-24 08:01:47

日常監(jiān)控服務器ZABBIX

2017-12-21 14:36:10

大數(shù)據(jù)健身智慧

2018-05-08 14:58:07

戴爾

2016-10-27 17:49:07

群暉群暉科技NAS

2023-11-24 11:20:04

functoolsPython

2019-04-19 08:47:00

前端監(jiān)控數(shù)據(jù)

2016-06-30 16:54:49

UCloud愛數(shù)云計算

2010-12-23 15:55:00

上網(wǎng)行為管理

2009-08-06 18:06:33

WebMethod框架

2014-04-22 09:51:24

LongAdderAtomicLong

2010-01-06 13:57:03

解析JSON

2023-11-16 08:55:14

CSS前端

2024-08-19 00:35:00

Pythondict遍歷列表推導式

2013-07-23 10:50:24

C程序

2011-07-21 13:52:43

組策略網(wǎng)絡打印機

2023-09-12 16:20:04

邊緣AI深度學習

2020-02-26 10:33:31

邊緣計算云計算

2023-05-29 07:15:52

設置打印機復印證件
點贊
收藏

51CTO技術棧公眾號