1. 修改VIM使用习惯
1.1 创建并读取默认VIM配置文件。
vim
1.2 在VIM窗口中依次输入:
:e ~/.vimrc
:r $VIMRUNTIME/vimrc_example.vim
:w
1.3 添加以下内容
" My personal options
set title
set number
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
set showmatch
set ruler
set incsearch
" Auto complete
inoremap ( ()
inoremap { {}
inoremap " ""
inoremap < <>
" Taglist options
let Tlist_Show_One_Flie = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Use_Right_Window = 1
1. ctags
1.1 安装ctags。
sudo apt-get install exuberant-ctags
1.2 在源代码根目录下生成tags文件。
ctag -R
1.3 在vim窗口里加载tags文件。
:set tags=[tags所在目录]/tags
1.4 常用快捷键
CTRL+] 跳转到当前函数/变量定义处
CTRL+T 跳转回去
2. taglist
2.1 在网站http://www.vim.org/scripts/script.php?script_id=273下载taglist_45.zip压缩包。
2.2 解压缩压缩包,有plugin和doc两个文件夹。
unzip taglist_45.zip
2.3 将这两个文件夹分别移动到/usr/share/vim/addons/下面对应位置。
sudo cp -r doc /usr/share/vim/addons/
sudo cp -r plugin /usr/share/vim/addons/
2.4 修改vim配置文件.vimrc。
sudo vim ~/.vimrc
2.5 添加以下内容:
" Taglis Options
let Tlist_Show_One_File=1 " just show the tag of this code, not all.
let Tlist_Exit_OnlyWindow=1 " if taglist window is the last, exit vim.
let Tlist_Use_Right_Window=1 " show taglist window in right.
2.6 在VIM窗口中使用taglist。