Win7系统上GVim为cscope增加数据库文件的bat文件--记录
::此.bat文件使用方法: 在Win7系统的cmd.exe环境下输入,xxx.bat Path:\xxx\yyy\zzz GVIMx 0/1,其中第二个参数是源代码路径,
::第三个参数是已打开的GVim的实例(且是空的,没有打开任何目录及文件),比如GVIM,GVIM1,GVIM2等;第四个参数控制是否在GVim实例中打开源代码根目录
@echo off
@echo "Update %1 cscope database..."
::下述命令是为了不改变执行此.bat的cmd.exe的系统PATH变量值, 且开启命令扩展
setlocal enableextensions
::路径c:\cygwin64\bin是为了使用下面的find命令,即linux下的find命令;放在%SYSTEMROOT%\System32前面
::是为了不使用Window下的find命令(Window下的find命令干什么用没有细究)
set PATH=D:\Program Files (x86)\Vim\vim81;C:\cygwin64\bin;%SYSTEMROOT%\System32
cd /d %1
@echo "clean ..."
if exist cscope.out del cscope.out
if exist tags del tags
if exist cscope.file del cscope.file
@echo "ctags ..."
::ctags.exe在D:\Program Files (x86)\Vim\vim81路径下
ctags -R *
@echo "cscope ..."
::在win10下以下这个命令行有点问题,现在把它换成两行;cmd这个if的语法真tm难理解/掌握
if not exist cscope.file ( @ echo "Generating cscope.file ..."
find ./ -name "*.c" -or -iname "*.s" -or -name "*.h"> cscope.file)
::cscope.exe在D:\Program Files (x86)\Vim\vim81路径下
cscope -Rbk -i cscope.file
@echo "Send cmd to %2 ..."
if %3 == 1 (vim --servername %2 --remote-send "<C-\><C-N>:Explore %1<CR>")
::vim.exe在D:\Program Files (x86)\Vim\vim81路径下,可用vim --help来查看如何使用
::DisconnectCscope()是定义在GVim启动文件中的函数(在D:\Program Files (x86)\Vim\vim81\_vimrc文件中)
::在win10下要把"DisconnectCscope()"改成'DisconnectCscope()'
vim --servername %2 --remote-expr "DisconnectCscope()"
copy %1\cscope.out %1\cscope_bak.out\
::win10环境下,下面有个问题,应该是--remote-send,不是--remote-expr,且_vimrc中要增加一句
:: let g:csprg="X:\xxx\xxx\cscope.exe",才能正常执行
vim --servername %2 --remote-expr "<C-\><C-N>:cs add %1\cscope_bak.out<CR>"
endlocal
cd /d D:\
@echo "OK!"
@echo on
以下是DisconnectCscope()的定义:
function DisconnectCscope()
cs kill -1
endfunction