vi安装Vundle+YouCompleteMe+注释快捷'scrooloose/nerdcommenter'

Vundle is short for Vim bundle and is a Vim plugin manager.

  • git上下载vundle

    $ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

  • 配置vundle插件
    1. Put this at the top of your .vimrc to use Vundle. Remove plugins you don't need, they are for illustration purposes.

      set nocompatible              " be iMproved, required
      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 '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' " git repos on your local machine (i.e. when working on your own plugin) Plugin 'file:///home/gmarik/path/to/plugin' " 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'}

      "下面这行是添加YouCompleteMe插件 Bundle 'Valloric/YouCompleteMe'
      "下面这行是添加注释插件,可以\cc注释,用\cu取消注注释
      Bundle 'scrooloose/nerdcommenter' " 所有vundle管理的插件都要在下面这行结束之前写好 call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help 下面是vi中的命令,可以打开vim之后命令模式下输入执行 " :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 " 下面可以加一些其它的自定义vi配置,比如说:
      set number
      set autoindent
      set cindent
      syntax enable
      syntax on
      "set c_Coo=256
      set backspace=indent,eol,start
      set tabstop=4
      set shiftwidth=4
      set smarttabet
      "set softabstop=4
      set expandtab
      set encoding=utf-8
      set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,lantin1
      filetype on
      filetype indent on
      filetype plugin indent on
    2. 下载插件:

      打开vim并运行命令 :PluginInstall,会自动把上面添加的YouCompleteMe下载到~/.vim/bundle/YouCompleteMe

      To install from command line: vim +PluginInstall +qall

  

  • 下载完成YouCompleteMe后,需要对其进行编译安装

    cd ~/.vim/bundle/YouCompleteMe
    ./install --clang-completer
     

这里需要安装有python-dev和cmake包

打开vim时提示No .ycm_extra_conf.py file detected, so no compile flags are available. Thus no semantic support for C/C++/ObjC/ObjC++.。只需要设置.ycm_extra_conf.py文件的位置即可,在.virmc文件中添加如下内容let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py',如果该路径下没有,有可能 在let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py',然后重新打开vim即可。  

From <http://hahaya.github.io/build-YouCompleteMe/>

  •  配置YouCompleteMe

"下面这部分没改

为了补全C++代码,在Linux下我们需要修改.ycm_extra_conf.py文件中的flags部分,使用-isystem添加系统的头文件进行解析,使用-I添加第三方的头文件进行解析,在flags部分后添加如下内容:

'-isystem', 

'/usr/include', 

'-isystem', 

'/usr/include/c++/4.8', 

10. '-isystem', 

11. '/usr/include', 

12. '/usr/include/x86_64-linux-gun/c++',                        

From <http://hahaya.github.io/build-YouCompleteMe/>

 

使用YouCompleteMe进行代码跳转可以通过绑定一个快捷键:nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>,很好理解,先跳到定义,如果没找到,则跳到声明处。\jd                               

From <http://feihu.me/blog/2014/intro-to-vim/>

 

:help map可以进入vi的快捷键的相关帮助文档

例如,本来需要按\jd转到变量的定义,那么现在只要按,jd就可以了

~/.vimrc:
let leader=','
letg:mapleader=','
nnoremap <leader>jd:Ycmcompleter GoToDefinitionElseDeclaration<CR>

设置注释的颜色

highlight Comment ctermfg=green guifg=green                      

From <http://blog.youkuaiyun.com/bendanban/article/details/7968055>

 

 

 

 

 

 

转载于:https://www.cnblogs.com/yuantf/p/5856209.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值