Make ultisnips snippet save the file in vim

221 Views Asked by At

I would like to define a ultisnips snippet which would enter some text and then save the file. I checked the help and think most likely the vimscript execution would be the way to go.

I've tried to search how to do that, here's what I tried:

snippet trigger ""
some_text
`!v w`
`!v execute ":w"`
`!v :execute ":w"`
`!v :w`
endsnippet

But all of them give me:

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

or similar. How to make vim execute simple save post-trigger?

0

There are 0 best solutions below