cenos7 默认使用
yum install vim
安装的是7的版本。已经很老了,无法使用最新YouCompleteMe.
由于需要在shell中编辑go、python等,就需要安装YouCompleteMe,来实现智能提示。
过程踩坑无数,就直接给出成功的方法好了。(每个步骤都解决不同的问题)
中间遇到最大的问题:
youcompleteme unavailable: requires vim compiled with python (2.7.1+ or 3.5.1+) support.
1.更新最新的源—自行修改国内源加速
sudo yum upgrade sduo yum update
2. 删除原装vim
yum -y remove vim*
3. 安装git –后续插件需要使用
sudo yum install git -y
4. 安装gcc等必要插件
sudo yum install centos-release-scl -y sudo yum install devtoolset-3-toolchain -y sudo yum install gcc-c++ -y sudo scl enable devtoolset-3 bash sudo yum install ncurses-devel -y yum -y install zlib*
5. 安装python3
sudo wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz&&tar zxvf Python-3.8.0.tgz&&mkdir /usr/local/python3&&cd Python-3.8.0&&./configure --prefix=/usr/local/python3 &&make && make install ln -s /usr/local/python3/bin/python3 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 ## 修改环境变量 ~/.bash_profile PATH=/usr/local/python3/bin:$PATH:$HOME/bin export PATH ## 使其生效 source ~/.bash_profile
6. 下载vim并安装
sudo wget -O vim.zip https://github.com/vim/vim/archive/master.zip&&unzip vim.zip -d ./&&cd ./vim-master/src&&./configure --with-features=huge --enable-pythoninterp=yes --enable-cscope --enable-fontset --enable-python3interp=yes --with-python3-config-dir=/usr/local/python3/lib/python3.8/config-3.8-x86_64-linux-gnu --prefix=/usr/local/vim &&make&&make install ## 创建链接 ln -s /usr/local/vim/bin/vim /usr/bin/vim
6. 检查是否支持python,python3
vim --version|grep python
7.安装YouCompleteMe
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe cd ~/.vim/bundle/YouCompleteMe git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/Vundle.vim git submodule update --init --recursive
8.修改vim配置
cat > ~/.vimrc <<EOF set nocompatible filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'gmarik/Vundle.vim' call vundle#end() filetype plugin indent on syntax on "自动语法高亮" EOF
9.安装Vundle插件
vim +PluginInstall +qall
10. 安装YouCompleteMe插件
sed -i -e "/Plugin 'gmarik\/Vundle.vim'/a\Plugin 'Valloric\/YouCompleteMe'" ~/.vimrc cd ~/.vim/bundle/YouCompleteMe&&./install.py --clang-completer --gocode-completer --tern-completer其中 –gocode-completer –tern-completer 为可选项