安装VIM8

下载源码,编译安装,默认会安装到/usr/local/bin下:

git clone https://github.com/vim/vim.git
cd vim/src
make
make install

如果make过程中报有关terminal的错误,并提示安装ncurses,则yum安装ncurses-devel后重新make和make install:

yum install ncurses-devel

安装vim-go插件

执行如下命令安装plug.vim插件管理器和vim-go插件:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
git clone https://github.com/fatih/vim-go.git ~/.vim/plugged/vim-go

然后在~/.vimrc里添加如下配置:

call plug#begin()
Plug 'fatih/vim-go'
call plug#end()

再然后执行vim命令,然后在vim里输入如下命令安装vim-go的依赖,然后退出vim即可:

:GoInstallBinaries

现在再打开go代码文件,就可以看到效果了。更复杂的用法详见vim-go插件文档。

参考资料

  • VIM
    • https://www.vim.org/download.php
    • https://github.com/vim/vim/blob/master/src/INSTALL
  • plug.vim
    • https://github.com/junegunn/vim-plug
  • vim-go
    • https://github.com/fatih/vim-go
    • https://github.com/fatih/vim-go-tutorial