Vim7 plugin 安装使用实战 大全 教程(lookupfile cscope ctags taglist )

87 views
Skip to first unread message

stan8688

unread,
Feb 21, 2008, 4:09:11 AM2/21/08
to 嵌入式linux

///////////////////////////////////////////////////////////////////////////
LOOKUPFILE

2.5 look the file use
:e ~/gd8808/jrtplib-3.7.1
3.install and use lookupfile plugin.

a. lookupfile.vim 需要 genutils.vim
download lookupfile-x.x.zip from http://www.vim.org/scripts/script.php?script_id=1581
cp zipfile's plugin/lookupfile.vim into ~/.vim/plugin
cp zipfile's doc/lookupfile.txt into ~/.vim/doc
cp zipfile's autoload/lookupfile.vim into ~/.vim/autoload

download genutils-x.x.zip from http://www.vim.org/scripts/script.php?script_id=197
cp zipfile's plugin/genutils.vim into ~/.vim/plugin
cp zipfile's autoload/genutils.vim into ~/.vim/autoload


:helptags ~/.vim/doc generate help index file then you can use :help
lookupfile cmd

b. use follow script to generate lookupfile's tagfile
##############################################################
lookupfile.sh
#!/bin/sh

#generate tag file for lookupfile plugin
echo -e "!_TAG_FILE_SORTED\t2\t/2=foldcase/" > filenametags
find src include /home/stan/installfiles/boost_1_34_1 -not -regex '.*\.
\(png\|gif\)' -type f -printf "%f\t%p\t1\n" | \
sort -f >> filenametags
########################################################33

c. vi ~/.vimrc
"#############lookupfile setting################
let g:LookupFile_MinPatLength = 2
let g:LookupFile_PreserveLastPattern = 0
let g:LookupFile_PreservePatternHistory = 1
let g:LookupFile_AlwaysAcceptFirst = 1
let g:LookupFile_AllowNewFiles = 0
if filereadable("./filenametags")
let g:LookupFile_TagExpr = '"./filenametags"'
endif

nmap <silent> <leader>lk <Plug>LookupFile<cr> ###LookupFile, \lk
nmap <silent> <leader>ll :LUBufs<cr> ####LUBufs, \ll
nmap <silent> <leader>lw :LUWalk<cr> ####LUWalk, \lw

d. use lookupfile
help: :help lookupfile

how to search file use lookupfile
:LookupFile
then input what you want search filename's example: rtppacket in up
window
Ctrl+N and Ctrl+P to select filename from filelist

how to search Buffers use lookupfile
:LUBufs
then input what you want search in the buffers example: rtppacket in
up windows
Ctrl+N and Ctrl+P to select filename from filelist

how to search Directory use lookup file
:LUWalk
then input /home/stan/gd8808/jrtplib-3.7.1/src
Ctrl+N and Ctrl+P to select filename from filelist to show all
Directory!!


//////////////////////////////////////////////////////////////////////

2设置
在VIM中执行”:helptags ~/.vim/doc”命令,生成help文件索引,然后就可以使用”:help lookupfile”命令查
看lookupfile插件的帮助文件了。
:set ts=4 set #####set tab=4 in vim


1. Taglist
vim下写程序必备插件,支持多种语言
http://www.vim.org/scripts/script.php?script_id=273
2. Bufexplorer
可以快速查看buffer,打开多个文件时很有用
http://www.vim.org/scripts/script.php?script_id=42
3.a.vim
很简单很实用的功能,在.c/.h .cpp/.h之间切换
http://www.vim.org/scripts/script.php?script_id=31
4.NERD_comments.vim
强大的注释工具,能自动识别多种语言
http://www.vim.org/scripts/script.php?script_id=1218
1安装Exuberant Ctags http://ctags.sourceforge.net (make install)
2.sudo apt-get install cscope
5.OmniCppComplete
我一直在寻找的最需要的功能,结合ctags生成的tags,能进行智能补全。
只对vim7有效,因为vim7支持下拉菜单。
http://www.vim.org/scripts/script.php?script_id=1520

插件列表:
a.vim : 同目录cpp/c与对应的.h文件之间切换,根据文件名
bufexplorer.vim : 用来切换buffer,修改过,改动了启动方式
comments.vim : 注释插件,在正常模式cm即可注释一行,v模式选中之后cm注释很多行,cu取消
matchit.vim : 对映大中小括号,#if等等等之间用%跳转
supertab.vim : 插入模式Tab补齐,Ctrl+N毕竟比较烦
tabswitch.vim : 我写的,使用以后可以ctrl+hjkl,在窗口之间跳转,用Ctrl+Tab可以切换buffer
taglist.vim : 显示多个tag的方式,修改过,现在针对一个文件显示比较简洁
vtreeexplorer.vim : 显示文件系统树


/////////////////////////////////////////////////////////////////////////
CSCOPE and ctags install and use

1安装Exuberant Ctags http://ctags.sourceforge.net (make install)
2.sudo apt-get install cscope
cscope -Rbkq 的含义是

-R: 在生成索引文件时,搜索子目录树中的代码
-b: 只生成索引文件,不进入cscope的界面
-k: 在生成索引文件时,不搜索/usr/include目录
-q: 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度

用cscope ctags 读源代码,编辑可执行脚本。

//////////////////////////////////////////////////////////////////////
#!/bin/sh

find /home/stan/gd8808/jrtplib-3.7.1/examples /home/stan/gd8808/
jrtplib-3.7.1/src /home/stan/gd8808/jthread-1.2.1/src -name "*.cpp" -
o -name "*.h" -o -name "*.c" > cscope.files
cscope -Rbq -i cscope.files
ctags -R

/////////////////////////////////////////////////////////////////////

接下来就可以用cscope ctags读源代码了,比如 vi driver/usb/host/ochi-s3c2410.c

ctags用法:
:tags 列出tag的stack
:Ctrl + ] 跳转到函数 , 结构的定义处。
:Ctrl + T 返回上次跳转。
:tp
:tn
:ts[elect][!] /^write_ 以write_开头的函数
:ts[elect][!] /$write_ 以write_结尾的函数
:tfirst
:tlast
:tag write_<TAB> 查找write_开头, 如果没有,继续TAB
:tag /block 包含block的

cscope用法:
cs add ./cscope.out
cs show
cscope commands:
add : Add a new database (Usage: add file|dir [pre-path]
[flags])
find : Query for a pattern (Usage: find c|d|e|f|g|i|s|t
name)
c: Find functions calling this function
d: Find functions called by this function
e: Find this egrep pattern
f: Find this file
g: Find this definition
i: Find files #including this file
s: Find this C symbol
t: Find assignments to
help : Show this message (Usage: help)
kill : Kill a connection (Usage: kill #)
reset: Reinit all connections (Usage: reset)
show : Show connections (Usage: show)

Reply all
Reply to author
Forward
0 new messages