Ubuntu16.04 IDE: 用Vim逐步打造一個IDE


目前打造完成的IDE主要有: terminator+Bundle+NERDtree+YCF(youcompleteme)+UltiSnips+新創建文件自動補充注釋和作者,版權信息等

 

1,當任務比較多的時候,如果在Ubuntu下切換多個終端,會比較麻煩,這里我找到一個比較好的終端(terminator)

sudo apt-get install terminator

安裝完之后的效果:

右鍵可以分割窗口或者新建tab, preference可以定制外觀

2,安裝YouCompleteMe

bundle是一個插件安裝管理器,安裝完成之后,就會在家目錄下面的.vim目錄生成bundle目錄及相關配置

我采用的是git安裝,bundle安裝太慢了,看不見進度

在家目錄下,cd .vim/bundle/

下載YouCompleteMe:

git clone --recursive https://github.com/Valloric/YouCompleteMe.git

以下為主要安裝命令和需要安裝的東西:

cd YouCompleteMe/

sudo apt-get install llvm-3.9 clang-3.9 libclang-3.9-dev libboost-all-dev
sudo apt-get install python-dev python3-dev
mkdir ~/.ycm_build
cd ~/.ycm_build

cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

cmake -G "Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

cmake --build . --target ycm_core --config Release

cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/

 

 

參考資料:

http://valloric.github.io/YouCompleteMe/

https://www.jianshu.com/p/d908ce81017a?nomobile=yes

http://blog.jobbole.com/58978/

 

3,用bundle安裝nerdtree

安裝:

  在.vimrc中,寫入需要安裝的插件

打開一個vim, 運行:BundleInstall

 補充2個小技巧:

1,shift + R可以自動刷新文件列表

2,在NERDTree樹形管理文件中,按ma可以創建文件或者目錄

使用

  1、在linux命令行界面,用vim打開一個文件。

  2、輸入  :NERDTree ,回車

  3、進入當前目錄的樹形界面,通過小鍵盤上下鍵,能移動選中的目錄或文件

  4、ctr+w+h  光標focus左側樹形目錄,ctrl+w+l 光標focus右側文件顯示窗口。多次摁 ctrl+w,光標自動在左右側窗口切換

  5、輸入:q回車,關閉光標所在窗口

 

 

安裝Vim 插件——UltiSnips 配置代碼片段( Bundle方式 )

1.安裝,在~/.vimrc中添加UltiSnips plugin.

Plugin 'SirVer/ultisnips' Plugin 'honza/vim-snippets'

2,然后在VIM的末行模式,鍵入命令 執行插件的安裝

:PluginInstall

3.配置的參考代碼在 ~/.vim/bundle/vim-snippets 

cp ~/.vim/bundle/vim-snippets/UltiSnips/c.snippets  ~/.vim/UltiSnips/

 

YCM和Ultisnips按鍵沖突解決方案(只使用TAB鍵 )

1,添加功能函數到.vimrc 

 1 function! g:UltiSnips_Complete()
 2   call UltiSnips#ExpandSnippet()
 3   if g:ulti_expand_res == 0
 4     if pumvisible()
 5       return "\<C-n>"
 6     else
 7       call UltiSnips#JumpForwards()
 8       if g:ulti_jump_forwards_res == 0
 9         return "\<TAB>"
10       endif
11     endif
12   endif
13   return ""
14 endfunction
15 
16 function! g:UltiSnips_Reverse()
17   call UltiSnips#JumpBackwards()
18   if g:ulti_jump_backwards_res == 0
19     return "\<C-P>"
20   endif
21 
22   return ""
23 endfunction
24 
25 
26 if !exists("g:UltiSnipsJumpForwardTrigger")
27   let g:UltiSnipsJumpForwardTrigger = "<tab>"
28 endif
29 if !exists("g:UltiSnipsJumpBackwardTrigger")
30   let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
31 endif
View Code

2,為上面的函數創建一個自動BufEnter

1 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger     . " <C-R>=g:UltiSnips_Complete()<cr>"
2 au InsertEnter * exec "inoremap <silent> " .     g:UltiSnipsJumpBackwardTrigger . " <C-R>=g:UltiSnips_Reverse()<cr>"
View Code

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM