Cscope How-to

来源:互联网 发布:支付宝和淘宝怎么更换 编辑:程序博客网 时间:2024/06/04 19:45
1 Cscope

apt-get install cscope


1.1 ~/.vimrc Settings

1.1.1 Cscope Settings

Copy the following comment to ~/.vimrc

以下的"(左双引号)后面的表示注释

例如:" add any database in current directory


if has("cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb

endif


1.1.2 Remember Last Location
Copy the following comment to ~/.vimrc

if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif

endif


1.1.3 Syntax Color off
Copy the following comment to ~/.vimrc

以下的"(左双引号)后面的表示注释

例如:"4 space, not Tab


hi comment ctermfg=6

syntax off

"4 space, not Tab

set tabstop=4
autocmd FileType c,cpp,h,java set shiftwidth=4 | set expandtab


1.1.4 Show the Whitespace
Copy the following comment to ~/.vimrc
以下的"(左双引号)后面的表示注释
例如:" whitespace

" whitespace
highlight whitespaceEOF ctermbg=red guibg=red
match whitespaceEOF /\s\+$/


1.2 ~/.bashrc Setting
Copy the following comment to ~/.bashrc


1.3 Support CPP and Java
# find ./ -name *.cpp > cscope.files
# find ./ -name *.hpp >> cscope.files
# find ./ -name *.c >> cscope.files
# find ./ -name *.h >> cscope.files
# find ./ -name *.java >> cscope.files
# cscope –kbRq


1.4 VI  快捷键

选中多行,复制,粘贴:Shift + v, y, p

选中多列,复制,粘贴:Ctrl + v, y, p

函数跳转:Ctrl + ]

函数跳转返回:Ctrl + o

跳到第一行: :0

跳到最后一行: :$


2 Taglist

2.1 Download taglist.vim from Internet

需要注册账号


2.2 Install
2.2.1 ~/.vimrc Setting
Copy the following comment to ~/.vimrc
以下的"(左双引号)后面的表示注释
例如:" show Tlist always

" show Tlist always
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Auto_Open=1
let Tlist_WinWidth=30

2.2.2 taglist.vim
mkdir ~/.vim/plugin
cp taglist.vim ~/.vim/plugin

2.2.3 taglist快捷键
跳到左边函数list窗口:ctrl + 按2次w键
跳到右边源码窗口:选择函数,按回车键
当左边函数list窗口被关闭时,可以在vim中用如下命令打开:“:TlistOpen”
需要关闭左边函数list窗口时,可以在vim中用如下命令关闭:“:TlistClose”;
或者使用 ” ctrl + 按2次w键“ 跳转到左边窗口,然后输入如下命令:“:q”


原创粉丝点击