打造屬於自己的vim利器


毋庸置疑vim很強大,然而沒有插件的話對於大多數人來說他的界面是很不友好的。下面簡單寫一下我對vim的配置

這是我的vim配置,裝的插件不是很多,對我來說已經夠用。左邊的側邊欄是NERD插件提供的,還裝了youcompleteme做代碼補全用,其他的就是對vimrc的配置了。

插件都是使用bundle來管理的,在安裝前需要在~下新建.vim/{plugin,doc,bundle}

1、安裝vundle

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

2、在vimrc文件中輸入如下配置,然后打開vim,運行 :PluginInstall,如果安裝成功,你將看到Done!的提示字樣。

3、YCM語法補全模塊的編譯

  不同於很多vim插件,YCM首先需要編譯,另外還需要有配置。在vim啟動后,YCM會找尋當前路徑以及上層路徑的.ycm_extra_conf.py.在~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py中提供了默認的模板

cd ~/.vim/bundle
cd YouCompleteMe
git clone https://github.com/Valloric/YouCompleteMe.git
git submodule update --init --recursive
./install.py --clang-completer

4、然后應該可以使用了

 

若想打造Python的IDE可以移步這里

 

附:.vimrc

"--------------------------------------------------------------------------
"                       Bundle
"--------------------------------------------------------------------------
"啟用Vim的特性,而不是Vi的(必須放到配置的最前邊)
set nocompatible
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 'scrooloose/nerdtree'
nnoremap <F2> :NERDTreeToggle<CR>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'
" 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
"autocmd vimenter * NERDTree
" 設置NerdTree(側邊欄)
map <F3> :NERDTreeMirror<CR>
map <F3> :NERDTreeToggle<CR>
" 關閉文件時同時關閉文件瀏覽器
let NERDTreeQuitOnOpen = 1
"當打開vim且沒有文件時自動打開NERDTree
autocmd vimenter * if !argc() | NERDTree | endif
" 只剩 NERDTree時自動關閉
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif


"--------------------------------------------------------------------------
"                       基本設置
"--------------------------------------------------------------------------
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif
" 設置編碼  
set encoding=utf-8
set fenc=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb2312,gb18030,big5
"顯示行號
set number
"設置背景色
"set bg=dark

"用 koehler 調色板
"colorscheme koehler
colorscheme desert
"隱藏工具欄和滑動條
set guioptions=aAce
"總是在窗口右下角顯示光標的位置
set ruler

"設置標簽欄
"最多30個標簽
set tabpagemax=30
"顯示標簽欄  
set showtabline=2

" 啟用鼠標
if has('mouse')
  set mouse=v
endif

"設置語法高亮
if &t_Co > 2 || has("gui_running")
syntax on
endif

" 輸入文本時隱藏鼠標
set mousehide
"--------------------------------------------------------------------------
"                       搜索設置
"--------------------------------------------------------------------------
"打開搜索高亮
set hlsearch
"忽略大小寫
set ignorecase
"在查找時輸入字符過程中就高亮顯示匹配點。然后回車跳到該匹配點。
set incsearch
"設置查找到文件尾部后折返開頭或查找到開頭后折返尾部。
set wrapscan

 


免責聲明!

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



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