vimrc配置文件
初始时是没有这个文件的,需要自己写
set nu “显示行号
syntax on “自动语法高亮
set shiftwidth=4 “默认缩进4个空格
set softtabstop=4 “使用tab时 tab空格数
set tabstop=4 “tab 代表4个空格
set expandtab “使用空格替换tab
安装vundle
说是安装,实际上只是将github上的工程clone到~/.vim/bundle/Vundle.vim/
目录下就可以了
详细安装方法参考https://github.com/VundleVim/Vundle.vim#quick-start
这个链接
在命令行下执行下面的命令(命令中后面的文件夹及其中的文件会自动生成)
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
更改vimrc配置文件,将下面的东西添加到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 'VundleVim/Vundle.vim'
Plugin 'artur-shaik/vim-javacomplete2'
" 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
注意,上面的内容与github上的样例不同,我将所有的example删除了,更换成此时我需要的javacomplete插件
就是在begin
和end
之间添加响应语句即可Plugin 'artur-shaik/vim-javacomplete2'
然后运行 vim ,再运行 :PluginInstall
然后出现下面这个界面
这个界面的意思应该是插件正在下载
经过很长时间之后(可能是阿里云的网速不行,所以花了很多时间),会出现如下界面
在上图中显示了Done!
这个字样
接下来再次修改vimrc文件,让这个插件与java文件关联起来
autocmd FileType java setlocal omnifunc=javacomplete#Complete
目前还是不好使,不知道为什么