1

For generating different placeholders like emails, names, and passwords, vim-fake looks like a really useful tool. The problem is that I'm using UltiSnips and vim-fake is seemingly designed for neosnippet—the snippets can be found here. Taking this simple code which is written for neosnippet,

snippet fakeint
abbr    fake#int()
options word
    `fake#int()`

Is there any way to write something equivalent for UltiSnips environment? I already tried the following codes but got no results.

snippet fakeint
`fake#int()`
endsnippet

and also,

snippet fakeint
`echo fake#int()`
endsnippet

1 Answer 1

1

The syntax to use a Vimscript expression in UltiSnips is `!v ...`, so I think what you're looking for is:

snippet fakeint
`!v fake#int()`
endsnippet

See :help UltiSnips-vimscript for all the details.


Note that you don't necessarily need to use a snippet manager to use the vim-fake functions, in Insert mode you could simply use CTRL-R = to insert the contents of an expression, then type the expression itself fake#int() (note that Tab completion should help you here) and finally press Enter.

This technique should allow you to insert the result of any Vimscript expressions in your text without having to configure them in your snippet manager.

1
  • 1
    Thank you so much. I find fakeint a little faster and easier to type than fake#int(). After writing all these snippets for UltiSnips, I would send my code on GitHub and provide a link here so that others could use it. Commented Jan 11, 2020 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.