YouCompleteMe——一个神奇的Vim插件

今天介绍一个灰常厉害的代码补全插件,他叫“你满足我”。

我是利用Vundle来安装管理Vim插件的,Vundle的安装很简单:

在终端里输入

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

然后将下面的代码放入 你的~/.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()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/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/'}
" Avoid a name conflict with L9
Plugin 'user/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

仔细看可以发现插件的安装,管理方法,即在 call vundle#begin() 和call vundle#end()之间放入你需要的插件,然后在vim中输入

:PluginInstall

YouCompleteMe的安装:

在.vimrc的合适位置 写上

Plugin 'Valloric/YouCompleteMe'

:wq之后 在vim里:PluginInstall 一下。
还没结束,现在还不能使用youcompleteme,因为这个插件是需要编译后才能使用的,那么就需要进入ycm所在文件夹,将他编译一下。

打开终端

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

上面的编译需要Cmake、最新的Xcode和最新的Command Line Tool,如果没有安装的你可以用Homebrew安装Cmake,然后在终端 用 xcode-selete 来安装最新的Xcode和CLT。

好了 现在可以去享受sublime text般的补全了~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值