windows 配置VIM+Taglist+NERDTreeToggle

0.说明

为了以后方便阅读java源码,在电脑上配置了安装VIM,并安装VIM两个插件。

1.安装VIM

官网下载安装。
地址:https://www.vim.org/

2.安装Vundle插件

Vundle是一款进行vim插件管理的插件。
地址:https://github.com/VundleVim/Vundle.vim
按照上面地址的Quick Start进行安装:

(网上有很多讲Linux下安装Vundle的教程,提到了VIM的配置文件“.vimrc”以及VIM的插件相关的一个文件夹“.vim”,这在windows上并不适用。VIM安装目录下有文件 _vimrc 和文件夹vimfiles分别对应上面两个文件)

1.安装git

地址:https://gitforwindows.org/
Alt

2.将Vundle从github上clone下来

1.在Vim的安装目录的vimfiles文件夹下新建文件夹命名为bundle。
2.将Vundle从github上clone到bundle中

git clone https://github.com/VundleVim/Vundle.vim.git ‘vim安装目录’/vimfiles/bundle/Vundle.vim

3.在VIM配置文件中配置Vundle
以下是从Vundle的github主页复制过来的并修改后的,将这段配置代码放在_vimrc的顶部。
这里注意:段前有单引号的行,表示是注释行。可以根据注释内容了解每行代码的意义所在。

从 “Plugin ‘VundleVim/Vundle.vim’” 行 到 “call vundle#end()” 行之间用来填写VIM插件名。Vundle运行时会根据这段代码所写的插件名自动从github上下载插件。写法:Plugin ‘plugin-name’。此处我已经将示例代码中插件行注释,不用可以删掉。

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=$VIM/vimfiles/bundle/Vundle.vim/
call vundle#begin($VIM/vimfiles/bundle/')
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/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/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/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

4.安装插件
启动VIM,在命令模式下输入:PluginInstall,VIM自动下载插件。

3.配置ctags

ctags是Taglist插件要使用的工具。使用Taglist需要先配置ctags。
下载ctags的windows应用。
地址:http://ctags.sourceforge.net/
解压下载的文件,将ctags.exe拷贝到VIM安装目录中的与vim.exe同级的文件夹中。博主下载的VIM版本是8.1,文件夹名为vim81。将这个文件夹(vim81)加入到环境变量中。

在_vimrc中加入以下内容:

set tags=tags;
set autochdir

4. 安装Taglist

在_vimrc配置文件增加插件的代码位置加入以下代码

Plugin 'taglist.vim'
let Tlist_Ctags_Cmd='ctags'
noremap <F8> :TlistToggle<CR>

vim中运行:PluginInstall
安装成功后在vim中运行":TlistToggle"可以打开或关闭Taglist边栏。

注意:配置代码中最后一行noremap :TlistToggle,将打开和关闭配置为快捷键F8。可以根据自己的选择进行修改,或者删除该行不设置快捷键。

vim使用Taglist的代码文件放在英文路径下,否则可能会遇到错误。

5.安装NERDTree

安装方式同Taglist
地址:https://github.com/scrooloose/nerdtree

Plugin 'scrooloose/nerdtree'
map <F2> :NERDTreeToggle<CR>

在_vimrc的顶部加入以下内容配置编码,防止NERDTree出错:

set encoding=utf-8
set termencoding=utf-8
set fileencoding=chinese
set fileencodings=ucs-bom,utf-8,chinese

set langmenu=zh_CN.utf-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章