win10上使用gvim+global/gtags的cmd启动批处理文件

时间:2020-08-01 12:37:08   收藏:0   阅读:116

rem 调用方式:xxx-xx.bat X:\yyy\aaa gvim 1 0

rem 第一个参数是源代码路径,第二个参数是 GVim实例的名称

rem 第三个参数控制是否在GVim显示代码目录,第四个参数控制是否更新GTAGS等文件

@echo off

rem 切换到代码根目录

cd /d %1

 

if %4 == 1 goto onlydis

@echo "clean ..."

if exist GTAGS del GTAGS

if exist gtags.files del gtags.files

if exist GRTAGS del GRTAGS

if exist tags del tags 

rem 要保证下面使用到的工具在环境变量PATH中:find(unix下的,非windows下的),gtags,gtags-cscope,ctags,global,vim,gvim等

@echo "gtags ..."

if not exist gtags.files (@echo "Gen gtags.files ..."

    find ./ -iname "*.c" -or  -iname "*.s" -or -iname "*.h" > gtags.files)

gtags -f gtags.files

@echo "tags ..."

ctags -R -L gtags.files

rem 以下以“后台模式”启动一个GVim,且GVim的工作路径就是源代码目录,名称为命令行中指定的

start /d %1 /b gvim --servername %2

@echo "Send cmd to %2 ..."

:onlydis

if %3 == 1 (vim --servername %2 --remote-send "<C-\><C-N>:Explore %1 <CR>")

@echo explore %errorlevel"

rem 非要以下面方式指定,在_vimrc中指定就不行,奇怪!

vim --servername %2 --remote-send "<C-\><C-N>:set csprg="X:\xxx\gtags-cscope.exe"<CR>"

@echo use gtags %errorlevel"

rem 我们在启动Gvim实例时,指定其路径为源代码路径了,故可以直接 cs add GTAGS

vim --servername %2 --remote-send "<C-\><C-N>:cs add GTAGS <CR>"

@echo cs add %errorlevel"

cd /d E:\

@echo "OK!"

@echo on

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!