作者flu (Crazy Rhythm)
看板Editor
标题Re: [vim ] 如何command下展开变数
时间Sun Mar 17 02:07:17 2019
(其余恕删)
: → ggirls: 有类似 <ctrl-R>" 这种直接展开的方法吗? 03/16 23:38
比如说有定义了这个function
function! My_Variable_Expand()
let l:_input = input("the var to be expanded: ")
if l:_input == "MYDOC"
return g:MYDOC
endif
return ""
endfunction
在执行了下面这行後
:cmap <F3> <c-r>=My_Variable_Expand()<CR>
以後在command mode按F3,於提示後再输入MYDOC
按enter後就会自动展开变数储存的值
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.26.208.31
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Editor/M.1552759640.A.C83.html
1F:→ Bellkna: 也可以在vimrc直接call function 03/17 09:09
2F:推 ggirls: 谢谢flu 03/18 16:21
3F:→ mars90226: 欸我上一篇推太快,还没看这篇XD OP了 03/20 18:37