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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章