vim相关

来源:互联网 发布:数据库基础ppt 编辑:程序博客网 时间:2024/05/16 11:48

find $LNX                                                                /
-path "$LNX/arch/*" ! -path "$LNX/arch/i386*" -prune -o               /
-path "$LNX/include/asm-*" ! -path "$LNX/include/asm-i386*" -prune -o /
-path "$LNX/tmp*" -prune -o                                           /
-path "$LNX/Documentation*" -prune -o                                 /
-path "$LNX/scripts*" -prune -o                                       /
-path "$LNX/drivers*" -prune -o                                       /
        -name "*.[chxsS]" -print > ~/cscope.files

vim折叠
:set fdm=marker设置为marker方式折叠
fdm为foldmethod缩写
创建折叠
zf
zf12G 从当前行到第12行折叠起来
12zf+向下折叠12行
12zf-向下折叠12行
关闭折叠
zc
展开折叠
zo
移动到一下个折叠处
zj
删除marker折叠
zd
zE删除所有marker折叠

有关折叠帮助
:help zf

自动触发补全
autocomplpop
http://www.vim.org/scripts/script.php?script_id=1879

csccope
1:准备 编译cscope:
./configure --with-flex
make
(chang to root)
make install
首先你的vim应该在编译的时候加入cscope选项,当你选择huge features时这个是默认编译进去的,然后复制cscope_maps.vim 到你的~/.vim/plugin文件夹中

2.应用 进入你的源代码文件夹
cscope -R
注:-R表示recursive 选择-R意味着直接进入cscope界面,此时?可以获得帮助,CTRL+D可以退出选择-b表示只是建立数据库 同ctags的使用方法类似,可以用vim -t 直接跳到相应的函数定义处

3.cscope search
a)下载配置文件:cscope_map.vim (
http://cscope.sourceforge.net/cscope_maps.vim
b)把cscope_map.vim里从 if has("cscope")? 到 endif里边的内容复制到/etc/vimrc里边去

在变量的定义下按CTRL + / 接着按 s可以查到(按下相应的数字跳转到相应的定义处) ,而跳回来可以用 CTRL + t ,按下CTRL + space 接着按 s 可以将vim水平分成两栏 'CTRL-W w' (or CTRL-W arrow key, or CTRL-W h/j/k/l for left/up/down/right)也可在此时按下 上/下/左/右的
close a window via 'CTRL-W c' (or good old ':q')
make the current window the only one via 'CTRL-W o'
split a window into two via 'CTRL-W s' (or 'CTRL-W v' for a vertical split)
open a file in a new window via ':spl[it] filename'] 按两下 CTRL + space 接着 s 可以将vim垂直分成两栏
其他搜索选项
'g' finds global definition(s) of a symbol
'c' finds all calls to a function
'f' opens the filename under the cursor

4.命令 :cscope function symbol foo :cs f s foo

5.cscope.files
设定这个变量$CSCOPE_DB,可以使你每次都要在含有cscope database的目录下打开文件了
find /my/project/dir -name '*.c' -o -name '*.h' > /foo/cscope.files
cd /foo
cscope -b CSCOPE_DB=/foo/cscope.out; export CSCOPE_DB

6.获得帮助
:help cscope man cscope

cscope -Rbq 。用ls查看有3个新文件生成cscope.in.out cscope.out cscope.po.out。
e> 测试cscope功能。 vim +cscope main.c 。查看ptn声明在哪个文件中的命令为 :cscope find g ptn。查看ptn被调用命令为:cscope


set tabstop=4
set nobackup
set cindent
set softtabstop=4
set shiftwidth=4
set smarttab
set smartindent
set hls
set nocompatible
set showmatch
set background=light
colorscheme desert
syntax on
set hlsearch
highlight Search term=reverse ctermbg=4 ctermfg=7
highlight Normal ctermbg=black ctermfg=white
highlight Comment ctermfg=blue
let g:winManagerWindowLayout='FileExplorer'
let g:persistentBehaviour=0
let g:winManagerWidth=20
let g:defaultExplorer=1
nmap fir :FirstExplorerWindow<cr>
nmap bot :BottomExplorerWindow<cr>
nmap wm :WMToggle<cr>

nmap tl :TlistToggle<cr>
let Tlist_Ctags_Cmd="ctags"
let Tlist_Show_One_File = 1 "taglist插件只显示当前文件的tag
let Tlist_Use_Right_Window = 1 "让taglist窗口显示在右边,默认在左边
let Tlist_Exit_OnlyWindow = 1 "退出vim时候退出taglist
set fdm=marker " 打开时自动关闭折叠