从 Bash 中确定 Vimfiles 目录

Decide Vimfiles directory from Bash

我想获取用户的vimfiles目录。鉴于用户可以假定使用 ~/.vim/ 以外的目录,从 vimvimfiles 变量中检索目录将是最佳的跨平台方式。但是怎么办?

我认为调用类似 vim -q -c COMMAND 的方法可能实际上是解决方案,但我不确定要使用的 COMMAND

我认为这会满足您的要求。

vim -c ':exec ":silent !echo ".&rtp | exec ":q!"'

这是我的笔记本电脑上的结果(为了便于阅读而重新格式化)。

/Users/dan/.vim,/Users/dan/.vim/bundle/ack,/Users/dan/.vim/bundle/fugitive,
/Users/dan/.vim/bundle/json,/Users/dan/.vim/bundle/my-ackmore,
/Users/dan/.vim/bundle/my-endwise,/Users/dan/.vim/bundle/pathogen,
/Users/dan/.vim/bundle/perl,/Users/dan/.vim/bundle/pgsql,
/Users/dan/.vim/bundle/quickrun,/Users/dan/.vim/bundle/repeat,
/Users/dan/.vim/bundle/signify,/Users/dan/.vim/bundle/statline,
/Users/dan/.vim/bundle/surround,/Users/dan/.vim/bundle/tcomment,
/usr/share/vim/vimfiles,/usr/share/vim/vim73,
/usr/share/vim/vimfiles/after,/Users/dan/.vim/after

您可以在 :help $VIM 中阅读有关 Vim 启动的更多信息。

更新: 根据要求,这里有一个变体,只显示列表中的第一个条目,我认为应该是 vimfiles :

vim -c ':exec ":silent !echo " . split(&rtp,",")[0] | exec ":q!"'