我正在寻找一种方法来处理!
类似的命令:wq!
。这是为了使我自己具有退出和/或写入文件的功能。我尝试了这个,但是当然没有用:
command! -nargs=0 SQ :call <SID>SaveAndQuit(0, 0)
command! -nargs=0 SWQ :call <SID>SaveAndQuit(1, 0)
command! -nargs=0 SQ! :call <SID>SaveAndQuit(0, 1)
command! -nargs=0 SWQ! :call <SID>SaveAndQuit(1, 1)
与功能function! <SID>SaveAndQuit( write, force )
。有没有办法处理!
?
是的,您应该使用-bang
属性,然后将其传递给函数,并!
在函数中进行处理。
:h bang
例如
command ... -bang XYZ call Function('foo', <bang>0)
您的功能:
func Function (argstr, bang)..
"here you check the a:bang to decide what should be done.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句