我想获取用户的vimfiles
目录。鉴于用户可以使用 ~/.vim/
以外的目录,从 vim
的 vimfiles
变量检索目录将是最佳交叉- 平台方式来做到这一点。但如何呢?
我认为调用像 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!"'
关于bash - 从 Bash 确定 Vimfiles 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33225511/