使用变量设置 Vim 选项
我有一个应该相当简单的问题,但我还没有找到解决方案。我正在编辑 .vimrc,并想使用变量中保存的结果设置一个选项。例如,我想将所有临时文件聚合到 ~/.vimetc 中。这就是我想做的,
let s:vimetc=$HOME.'/vimetc/'
set backupdir=s:vimetc.'backups/'
set directory=s:vimetc.'vimswap/'
set viewdir=s:vimetc.'vimswap/'
当然,set 不会解析变量,所以我最终得到的是文字 |s:vimetc.'backups/'|,根本不是我想要的。我尝试使用 &s:vimetc 得到类似的结果。有谁知道该怎么做?
I've a question that should be fairly simple, but I have yet to find a solution for. I'm editing my .vimrc and would like to set an option using results saved in a variable. For example, I would like to aggregate all my temporary files in ~/.vimetc. Here's what I would like to do,
let s:vimetc=$HOME.'/vimetc/'
set backupdir=s:vimetc.'backups/'
set directory=s:vimetc.'vimswap/'
set viewdir=s:vimetc.'vimswap/'
Of course, set doesn't resolve variables so I just end up with the literal |s:vimetc.'backups/'|, not at all what I would like. I tried using &s:vimetc with similar results. Does anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://vimdoc.sourceforge.net/htmldoc/eval.html#:let-option
http://vimdoc.sourceforge.net/htmldoc/eval.html#:let-option