2

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

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

4

1 回答 1

4

我认为这会做你想要的。

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

你可以阅读更多关于 Vim 启动的信息:help $VIM

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

vim -c ':exec ":silent !echo " . split(&rtp,",")[0] | exec ":q!"'
于 2015-10-20T00:10:55.033 回答