VIM配置C語言IDE

1.安裝Vundle插件

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

2.打開vimrc文件添加如下配置:

打開vimrc

$ gedit  ~/.vimrc

添加如下配置

    "********************************************************
    "                   一般性配置                          *
    "********************************************************

    "關閉vim一致性原則
    set nocompatible

    "顯示行號
    set number

    "設置在編輯過程中右下角顯示光標的行列信息
    set ruler

    "在狀態欄顯示正在輸入的命令
    set showcmd

    "設置歷史記錄條數
    set history=1000

    "設置取消備份 禁止臨時文件的生成
    set nobackup
    set noswapfile

    "設置匹配模式
    set showmatch

    "設置C/C++方式自動對齊
    set autoindent
    set cindent

    "開啓語法高亮功能
    syntax enable
    syntax on

    "指定配色方案爲256色
    set t_Co=256

    "設置搜索時忽略大小寫
    set ignorecase

    "配置backspace的工作方式
    set backspace=indent,eol,start

    "設置在vim中可以使用鼠標
    set mouse=a

    "設置tab寬度
    set tabstop=4

    "設置自動對齊空格數
    set shiftwidth=4

    "設置退格鍵時可以刪除4個空格
    set smarttab
    set softtabstop=4

    "將tab鍵自動轉換爲空格
    set expandtab

    "設置編碼方式
    set encoding=utf-8

    "自動判斷編碼時 依次嘗試以下編碼
    set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

    "檢測文件類型
    filetype on

    "針對不同的文件採取不同的縮進方式
    filetype indent on

    "允許插件
    filetype plugin on

    "啓動智能補全
    filetype plugin indent on


    "*********************************************************
    "                  vundle 配置                           *
    "*********************************************************

    set rtp+=~/.vim/bundle/vundle/
    call vundle#rc()

    " let Vundle manage Vundle
    Bundle 'gmarik/vundle'

    " My Bundles here:

    Bundle 'tpope/vim-fugitive'
    Bundle 'Lokaltog/vim-easymotion'
    Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
    Bundle 'tpope/vim-rails.git'
    Bundle 'taglist.vim'
    Bundle 'The-NERD-tree'
    Bundle 'Syntastic'
    Bundle 'L9'
    Bundle 'FuzzyFinder'
    Bundle 'Lokaltog/vim-powerline'
    Bundle 'Valloric/YouCompleteMe' 


    "*****************************************************
    "                   taglist配置                      *
    "*****************************************************

    "不顯示"press F1 to display help"
    let Tlist_Compact_Format=1

    "窗口在左側顯示
    let Tlist_Use_Right_Window=1

    "只顯示當前文件的tags
    let Tlist_Show_One_File=1  

    "高亮顯示
    let Tlist_Auto_Highlight_tag=1

    "隨文件自動更新
    let Tlist_Auto_Update=1

    "設置寬度
    let Tlist_WinWidth=30       

    "taglist窗口是最後一個窗口,則退出vim
    let Tlist_Exit_OnlyWindow=1 

    "單擊跳轉
    let Tlist_Use_SingClick=1

    "打開關閉快捷鍵
    nnoremap <silent> <F8> :TlistToggle<CR>




    "********************************************************
    "                      NERD_Tree 配置                   *
    "********************************************************

    "顯示增強
    let NERDChristmasTree=1

    "自動調整焦點
    let NERDTreeAutoCenter=1

    "鼠標模式:目錄單擊,文件雙擊
    let NERDTreeMouseMode=2

    "打開文件後自動關閉
    let NERDTreeQuitOnOpen=1

    "顯示文件
    let NERDTreeShowFiles=1

    "顯示隱藏文件
    let NERDTreeShowHidden=1

    "高亮顯示當前文件或目錄
    let NERDTreeHightCursorline=1

    "顯示行號
    let NERDTreeShowLineNumbers=1

    "窗口位置
    let NERDTreeWinPos='left'

    "窗口寬度
    let NERDTreeWinSize=31

    "不顯示'Bookmarks' label 'Press ? for help'
    let NERDTreeMinimalUI=1

    "快捷鍵
    nnoremap <silent> <F4> :NERDTreeToggle<CR>



    "*****************************************************
    "           YouCompleteMe配置                        *
    "*****************************************************

    "leader映射爲逗號“,”
    let mapleader = ","  

    "配置默認的ycm_extra_conf.py
    let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py' 

    "按,jd 會跳轉到定義
    nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>   

    "打開vim時不再詢問是否加載ycm_extra_conf.py配置
    let g:ycm_confirm_extra_conf=0   

    "使用ctags生成的tags文件
    let g:ycm_collect_identifiers_from_tag_files = 1 


    "*****************************************************
    "           Syntastic配置                            *
    "*****************************************************


    let g:Syntastic_check_on_open=1

3.安裝所有配置中的所有插件

在添加好配置的文件中 ESC ->”shfit” + “;”->BundleInstall
即在vim中輸入BundleInstall命令即可.

4.問題與解決

這裏寫圖片描述

$ sudo pip install future

一般都內置了future,如果未能解決上述問題,將vimrc下的bundle刪除重新下載,

這裏寫圖片描述

確保最後都下載完了,才能關閉此窗口,最後一個YouCompleteMe文件特別大二百多M,利用一下命令查看文件大小是否完成:

du -sh ./.vim/bundle/YouCompleteMe

這裏寫圖片描述

可見此文件在緩慢增長。

自動安裝

傳送門

無插件版本

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章