vim 重用 cscope 或者ctag生成的索引文件

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
huangyingw
帖子: 53
注册时间: 2008-03-05 21:42

vim 重用 cscope 或者ctag生成的索引文件

#1

帖子 huangyingw » 2008-12-24 22:55

如题,请教一下。
按照网上的做法,先生成索引文件,再用vim打开相应目录下的代码文件。
我的问题是:对于这个已经做了索引的目录, 是不是每次用vim打开相关文件之前都得先再重新生成索引一次?
能不能重用之前生成的索引文件呢?
头像
qianjigui
帖子: 221
注册时间: 2007-06-26 23:50
来自: WHU
联系:

Re: vim 重用 cscope 或者ctag生成的索引文件

#2

帖子 qianjigui » 2008-12-25 1:11

我是加个快捷键专门用于生成索引。毕竟很多时候,我们需要大量的临时索引和配置。
我没有对vim的配置文件做过多的了解,不过就从我对其的使用来看,应该是可以完成你的想法。

这是我的配置文件:

代码: 全选

"========================================================
" Set vim colorscheme
colorscheme desert
"========================================================

"========================================================
" syntax highlight
syntax enable
syntax on
"========================================================

"========================================================
" Add the WinManagerWindow
" =======================================================
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<cr>

"========================================================
" Add the tagList
"========================================================
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1

"========================================================
" SuperTab Retain Completion
" =======================================================
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
let g:SuperTabDefaultCompletionDiscovery = [
      \ "&completefunc:<C-X><C-U>",
      \ "&omnifunc:<C-X><C-O>",
      \ "&completeNowFile:<C-X><C-P>",
      \ "&completeTags:<C-X><C-]>",
      \ ]

"========================================================
" Set the nocompatible for the vim not vi
" =======================================================
set nocompatible
set nu

"========================================================
" Set the key map
" =======================================================
map <F4> :w <CR> :!ctags -R % <CR> :TlistUpdate <CR>
imap <F4> <Esc><F4>
imap <F5> <Esc><F5>
imap <F6> <Esc><F6>
inoremap <C-space> <Esc>

map <C-s> <Esc>:w<CR>a
imap <C-s> <Esc><C-s>

map <C-f> :%s/
imap <C-f> <Esc><C-f>

map <A-a> <Esc>ggVG
imap <A-a> <Esc><A-a>
map <C-c> "+y
imap <C-c> <Esc><C-c>
map <C-v> p
imap <C-v> <Esc><C-v>

"========================================================
" Set the local
" =======================================================
setlocal encoding=utf-8
setlocal expandtab
setlocal autowrite
setlocal tabstop=2 shiftwidth=2 softtabstop=2
setlocal autoindent

"========================================================
" Set the filetype
" =======================================================
filetype on
filetype plugin indent on
filetype indent on
filetype plugin on

"========================================================
" Set the auto complete opt 
" =======================================================
set completeopt=longest,menu
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete

"========================================================
" Set the vim for the dictionary and other basic setting
" =======================================================
"设置文件浏览器目录为当前目录
set autochdir
"设置编码
set enc=utf-8
"设置文件编码
set fenc=utf-8
"设置文件编码检测类型及支持格式
set fencs=utf-8,gb18030,gbk,gb2312
最后我想说我也是个vim的初学者,网上有很多强大的vim配置文件和相关讲解,如果想好好使用建议去认真学习。
huangyingw
帖子: 53
注册时间: 2008-03-05 21:42

Re: vim 重用 cscope 或者ctag生成的索引文件

#3

帖子 huangyingw » 2008-12-26 22:54

qianjigui 写了:我是加个快捷键专门用于生成索引。毕竟很多时候,我们需要大量的临时索引和配置。
我没有对vim的配置文件做过多的了解,不过就从我对其的使用来看,应该是可以完成你的想法。

这是我的配置文件:

代码: 全选

"========================================================
" Set vim colorscheme
colorscheme desert
"========================================================

"========================================================
" syntax highlight
syntax enable
syntax on
"========================================================

"========================================================
" Add the WinManagerWindow
" =======================================================
let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<cr>

"========================================================
" Add the tagList
"========================================================
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1

"========================================================
" SuperTab Retain Completion
" =======================================================
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
let g:SuperTabDefaultCompletionDiscovery = [
      \ "&completefunc:<C-X><C-U>",
      \ "&omnifunc:<C-X><C-O>",
      \ "&completeNowFile:<C-X><C-P>",
      \ "&completeTags:<C-X><C-]>",
      \ ]

"========================================================
" Set the nocompatible for the vim not vi
" =======================================================
set nocompatible
set nu

"========================================================
" Set the key map
" =======================================================
map <F4> :w <CR> :!ctags -R % <CR> :TlistUpdate <CR>
imap <F4> <Esc><F4>
imap <F5> <Esc><F5>
imap <F6> <Esc><F6>
inoremap <C-space> <Esc>

map <C-s> <Esc>:w<CR>a
imap <C-s> <Esc><C-s>

map <C-f> :%s/
imap <C-f> <Esc><C-f>

map <A-a> <Esc>ggVG
imap <A-a> <Esc><A-a>
map <C-c> "+y
imap <C-c> <Esc><C-c>
map <C-v> p
imap <C-v> <Esc><C-v>

"========================================================
" Set the local
" =======================================================
setlocal encoding=utf-8
setlocal expandtab
setlocal autowrite
setlocal tabstop=2 shiftwidth=2 softtabstop=2
setlocal autoindent

"========================================================
" Set the filetype
" =======================================================
filetype on
filetype plugin indent on
filetype indent on
filetype plugin on

"========================================================
" Set the auto complete opt 
" =======================================================
set completeopt=longest,menu
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete

"========================================================
" Set the vim for the dictionary and other basic setting
" =======================================================
"设置文件浏览器目录为当前目录
set autochdir
"设置编码
set enc=utf-8
"设置文件编码
set fenc=utf-8
"设置文件编码检测类型及支持格式
set fencs=utf-8,gb18030,gbk,gb2312
最后我想说我也是个vim的初学者,网上有很多强大的vim配置文件和相关讲解,如果想好好使用建议去认真学习。
收到,,与君共勉。。
回复