vim常用配置

vim常用配置及插件

  1. 基础vimrc配置文件:~/.vimrc

    set nu
    set ts=4
    set expandtab
    set t_Co=256
    colorscheme molokai
    syntax on
    set cursorline
    set cc=81
        
    set laststatus=2
    "let g:Powerline_symbols='fancy'
    let g:Powerline_symbols='unicode'
        
    filetype off
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    Plugin 'VundleVim/Vundle.vim'
    Plugin 'Lokaltog/vim-powerline'    "底部状态栏
    Plugin 'Valloric/YouCompleteMe'    "代码自动提示
    Plugin 'dgryski/vim-godef'         "golang代码跳转
    call vundle#end()
    filetype plugin indent on
  2. mac上安装需要先装MacVim代替系统自带vim,参照官方:https://github.com/Valloric/YouCompleteMe#mac-os-x

    > brew install macvim --with-override-system-vim
  3. 进入vim,执行:PluginInstall,安装所有插件

  4. 安装YouCompleteMe相关依赖

    > cd ~/.vim/bundle/YouCompleteMe
    > ./install.py

Golang代码自动补全及跳转支持

  1. YouCompleteMe支持golang代码补全

    > cd ~/.vim/bundle/YouCompleteMe
    > ./install.py --go-completer
  2. godef安装(vim-godef插件必需,用于代码跳转)

    > go get -v github.com/rogpeppe/godef
    > go install -v github.com/rogpeppe/godef
  3. godef快捷键配置:使用c-]或者gd进行跳转,文件 ~/.vim/bundle/vim-godef/plugin/godef.vim中添加下面两行

    autocmd FileType go nnoremap <buffer> gd :call GodefUnderCursor()<cr>
    autocmd FileType go nnoremap <buffer> <C-]> :call GodefUnderCursor()<cr>
comments powered by Disqus