質問

I use vim on both FreeBSD and Linux os, sharing the same .vimrc configuration file. There's one problem that on FreeBSD the ctags binary path is /usr/local/bin/exctags, while on linux it's /usr/bin/ctags. So how to detect the OS type and set ctags binary path separately?

UPDATE:
I found once the taglist plugin is installed, it will automatically detect ctags path and store it in g:Tlist_Ctags_Cmd variable.

役に立ちましたか?

解決

I faced the same issue some time ago, and I solved it this way:

if executable('exctags')
   " On Free-BSD, exuberant ctags is installed as exctags
   let l:sCtagsName = 'exctags'
elseif executable('ctags')
   let l:sCtagsName = 'ctags'
endif

and then I use variable l:sCtagsName to call ctags. This works nice for me.

And, as long as you use ctags in Vim, why not to use the plugin Indexer which is made especially for that? It automatically generates tags for all files of project(s) and keeps tags up-to-date. You might want to check my another answer to get more details.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top