In Ultisnips, is there a way to create a snippet that will replace empty space in the snippet with a * character upon exiting Insert mode (or as I type)?

For example, I have a snippet that looks like so:

snippet cch
/* ${1} */

After expanding this snippet, I would like to fill the space around the input ${1} with * characters after exiting Insert mode such that the width of this line will match the lines above and below.

So if I type cch <tab> and then Function Prototypes <Esc> it will look like the following:

/***** Function Prototypes ****/

Is this possible?


1 Answer 1


In my case I have found in plugged/vim-snippets/UltiSnips/all.snippets a snippet called box that makes something like that:

-  some text inside  -

After reading a little bit more the code I figured out that if you set your filetype like :setf c and type box<tab>you will get your something like:

*  my text  *

This means you just have to make a slightly different version of all.snippets

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.