安装vim的YouCompleteMe插件

1. 安装vim7.4,从官网下载vim7.4.tar.gz(因为YouCompleteMe只支持vim7.3.584以上版本)

         ./configure  --enable-multibyte --enable-pythoninterp=yes --enable-python3interp=yes

        make & make install

        export PATH=/usr/local/bin:$PATH


2. 安装clang_3_3, 建议直接在官网下载编译好的版本

        export PATH=/usr/clang_3_3/bin:$PATH


3. 编译和安装、使用YouCompleteMe(https://github.com/Valloric/YouCompleteMe)

 a. 安装管理插件的VIM插件(vunble)

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

 b. 下载YouCompleteMe至本地

          git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe

 c. 继续更新第三方文件

        git submodule update --init --recursive


 4. vim ~/.vimrc,往里边添加以下这段内容(示例):

filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
call vundle#end()
filetype plugin indent on

5. 继续以下操作

cd ~
mkdir ycm_build 
cd ycm_build 
cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp 
或者通过指定clang_3_3的方式:cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/root/clang_3_3/ . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
make ycm_core
make

     配置补全,在vimrc中加入

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" YouCompleteMe
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'

     并在.ycm_extra_conf.py'添加如下代码,以支持STL的成员函数显示。

'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include',
'-isystem',
'/Library/Developer/CommandLineTools/usr/include',
'-isystem',
'/Library/Developer/CommandLineTools/usr/bin/../lib/c++/v1',
'-isystem',
'.'


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Vim YouCompleteMe插件安装步骤如下: 1. 安装Vundle插件管理器,可以通过以下命令进行安装git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim 2. 在.vimrc文件中添加以下内容: 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() " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' " YouCompleteMe插件 Plugin 'Valloric/YouCompleteMe' " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required 3. 打开Vim,运行以下命令进行插件安装: :PluginInstall 4. 安装完成后,进入YouCompleteMe插件目录,运行以下命令进行编译: cd ~/.vim/bundle/YouCompleteMe ./install.py --clang-completer 5. 编译完成后,重新打开Vim即可使用YouCompleteMe插件。 ### 回答2: Vim YouCompleteMeVim编辑器的一个强大的自动补全插件,它可以在你输入时提供不同类型的自动完成选项,如变量名、函数名、类名等。它支持多种编程语言,包括C、C++、Python、JavaScript等。下面是如何安装YouCompleteMe插件。 1.安装vim插件管理器Vundle:从https://github.com/VundleVim/Vundle.vim下载最新的Vundle源代码。将下载的文件解压,并将其放置在~/.vim/bundle/Vundle.vim目录下; 2.加载YouCompleteMe插件:在vim配置文件(.vimrc)中,添加以下代码: `set rtp+=~/.vim/bundle/Vundle.vim` `call vundle#begin()` `Plugin 'Valloric/YouCompleteMe'` `call vundle#end()` 3.编译YouCompleteMe插件:执行以下命令来编译YouCompleteMe: `cd ~/.vim/bundle/YouCompleteMe` `./install.py --clang-completer`(如果你想支持其他语言,可以在安装时使用其他的选项) 4.重启Vim:重新启动Vim。 5.开启YouCompleteMe插件:在命令模式下,执行以下命令来开启YouCompleteMe插件: `:PluginInstall` 6.设置YouCompleteMe插件:在vim配置文件(.vimrc)中,添加以下代码来设置YouCompleteMe插件: `let g:ycm_min_num_of_chars_for_completion=2` `let g:ycm_autoclose_preview_window_after_completion=1` `let g:ycm_collect_identifiers_from_tags_files=1` `let g:ycm_complete_in_comments_and_strings=1` 以上是YouCompleteMe插件安装步骤及设置方法,希望对您有所帮助。 ### 回答3: 1. 安装vim 在开始安装youcompleteme插件之前,必须确保vim已经被正确地安装在您的电脑上。对于Ubuntu和Debian用户,可以使用以下命令来安装: ``` sudo apt-get install vim ``` 2. 安装Vundle Vundle是一个用于管理vim插件的工具。在安装youcompleteme之前,我们需要先安装Vundle。可以使用以下命令来安装: ``` git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim ``` 3. 安装youcompleteme 安装youcompleteme需要先确保一些依赖项已经被安装在您的电脑上。对于Ubuntu和Debian用户,可以使用以下命令来安装: ``` sudo apt-get install build-essential cmake python-dev python3-dev ``` 在安装完这些依赖项之后,我们需要进入vim并使用Vundle安装youcompleteme插件。 首先,在命令行上输入vim并按回车键,进入vim。 其次,在vim中,按下"Esc"键来进入命令模式。 然后,输入以下命令,以从您的vimrc文件中安装youcompleteme插件: ``` :PluginInstall ``` 在您输入该命令后,Vundle将开始下载并安装youcompleteme插件。此时需要安装插件的依赖项,输入以下命令: ``` cd ~/.vim/bundle/YouCompleteMe python install.py --clang-completer ``` 这将花费一些时间来完成youcompleteme插件安装。 4. 配置youcompleteme 安装youcompleteme后,您需要在.vimrc文件中进行一些配置。例如,您可以设置允许youcompleteme在打开文件时立即启动自动补全。添加以下设置: ``` autocmd InsertEnter * if !&completefunc | setlocal completefunc=YouCompleteMe\|UltiSnips#Complete | endif ``` 完成上述步骤后,youcompleteme插件将在您的vim中运行,让您更加高效地进行编码工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值