Skip to content

vimplus

检查vim版本

首先查看一下vim的版本 检查一下是否是8.0及以上的版本。现在ubunbtu默认的都 是8.0以上的版本。

shell
vim --version

然后查看一下当前的 vim 是否支持 python3 若出现 +python3 这一项表示支持, - python3表示不支持。

shell
vim --version | grep python

安装vimplus

在线安装

vimplus在线安装方式(国内网络环境下失败率太高,不推荐):

shell
sudo apt install git
git clone https://github.com/chxuan/vimplus.git ~/.vimplus
cd ~/.vimplus
./install.sh

速度慢,可以把git换为

shell
git clone https://gitee.com/cskaoyan123/vimplus.git ~/.vimplus

离线安装

vimplus离线安装方式(在网络不佳情形,推荐):

shell
sudo apt install vim-youcompleteme # 使用包管理器安装ycm
rm -rf ~/.vim ~/.vimplus # 删除本地之前已下载内容

vim.tar.gz 解压到自己家目录 ,将 vimplus.tar.gz 解压到自己家目录

然后再次进去.vimplus执行 ./install.sh即可

等待过程中, 会出现让你用 python2 还是 python3 编译自动补全插件

YouCompleteMe( ycm), 这里选择 3 即可。

如果出现下图,表示 vimplus 安装成功了!

shell
        __                __
__   __/_/___ ___  ____  / /_  _______
\ \ / / / __ `__ \/ __ \/ / / / / ___/
 \ V / / / / / / / /_/ / / /_/ (__  )
  \_/_/_/ /_/ /_/ ,___/_/\____/____/
               /_/                     ...is now installed!


Just enjoy it!
p.s. Follow me at https://github.com/chxuan.

然后新建软连接

shell
ln -s ~/.vimplus/.vimrc  ~/.vimrc

安装报错解决

错误1

安装完成后可能会出现YouCompleteMe只支持在 vim 8.xxx+ 的版本上才能运行的错误,此时需要对 vim 进行升级。

而如果你查看 Vim 网站,你会发现 Vim 已经发布了更新的版本。

在写这篇文章的时候,Vim 9.0 已经发布,但在 Ubuntu 仓库中还没有。

好消息是,你可以使用一个 非官方的,但积极维护的 PPA 安装最新的 Vim。

使用 PPA 在 Ubuntu 上安装 Vim 9

如果你有特定的 Vim 配置文件,为它们做个备份也无妨。

现在,要安装最新的 Vim 版本,先添加 PPA 仓库:

shell
sudo add-apt-repository ppa:jonathonf/vim

你不需要在 Ubuntu 上更新软件包缓存,但其他发行版如 Mint 可能仍然需要:

shell
sudo apt update

现在,使用下面的命令来安装 PPA 提供的最新 Vim 版本:

shell
sudo apt install vim -y

安装完成最新版本后启动 vim,我又遇到了 ycm server 没有运行的错误,重启后仍然报错,尝试重新安装 vimplus 后问题解决。

错误2

引用自 https://blog.csdn.net/sinat_16489689/article/details/109412955

错误描述
g:NERDTreeIndicatorMapCustom' is deprecated

shell
[nerdtree-git-status] option ‘g:NERDTreeIndicatorMapCustom’ is deprecated, please use ‘g:NERDTreeGitStatusIndicatorMapCustom’ Press ENTER or type command to continue
  • 解决办法引用自@chxuan
  • 问题产生原因本插件的原作者@Xuyuanp在更新版本后改变了变量的名字

问题定位
执行: sudo vim ~/.vimrc 在文件中找到如下代码(行号为我的文件中的行号)

shell
308 let g:NERDTreeIndicatorMapCustom = {
309     \ "Modified"  : "✹",
310     \ "Staged"    : "✚",
311     \ "Untracked" : "✭",
312     \ "Renamed"   : "➜",
313     \ "Unmerged"  : "═",
314     \ "Deleted"   : "✖",
315     \ "Dirty"     : "✗",
316     \ "Clean"     : "✔︎",
317     \ 'Ignored'   : '☒',
318     \ "Unknown"   : "?"
319     \ }

修改line 308 g:NERDTreeIndicatorMapCustomg:NERDTreeGitStatusIndicatorMapCustom

shell
307 " nerdtree-git-plugin
308 let g:NERDTreeGitStatusIndicatorMapCustom = {
309     \ "Modified"  : "✹",
310     \ "Staged"    : "✚",
311     \ "Untracked" : "✭",
312     \ "Renamed"   : "➜",
313     \ "Unmerged"  : "═",
314     \ "Deleted"   : "✖",
315     \ "Dirty"     : "✗",
316     \ "Clean"     : "✔︎",
317     \ 'Ignored'   : '☒',
318     \ "Unknown"   : "?"
319     \ }

问题解决!

cd wbash: cannot create temp file for here-document: Permission denied

单独安装ycm

shell
rm -rf ~/.vim/plugged/YouCompleteMe
sudo apt install vim-youcompleteme
vim-addons install youcompleteme

函数自动跳转

参考 https://blog.csdn.net/ballack_linux/article/details/71036072

wd54期中vim的课件 点击查看