我想定义一个 ultisnips 片段,它会输入一些文本然后保存文件。我检查了帮助,并认为 vimscript 执行很可能是要走的路。
我试图搜索如何做到这一点,这是我尝试过的:
snippet trigger ""
some_text
`!v w`
`!v execute ":w"`
`!v :execute ":w"`
`!v :w`
endsnippet
但他们都给了我:
File "~/.vim/bundle/ultisnips/pythonx/UltiSnips/snippet/definition/_base.py", line 442, in launch
snippet_instance.update_textobjects()
File "~/.vim/bundle/ultisnips/pythonx/UltiSnips/text_objects/_snippet_instance.py", line 80, in update_textobjects
if obj._update(done):
File "~/.vim/bundle/ultisnips/pythonx/UltiSnips/text_objects/_viml_code.py", line 20, in _update
self.overwrite(_vim.eval(self._code))
File "~/.vim/bundle/ultisnips/pythonx/UltiSnips/_vim.py", line 121, in eval
rv = vim.eval(as_vimencoding(text))
error: Vim:E121: Undefined variable: w
或类似的。如何让vim执行简单的保存后触发?