nvim-snippy icon indicating copy to clipboard operation
nvim-snippy copied to clipboard

normal mode after completing snippet :question:

Open sigzegv opened this issue 4 years ago • 2 comments

Is there a way to switch to normal mode and not stay in insert mode after ending a snippet completion ? It would like to be able to do that for specific snippets.

sigzegv avatar Nov 26 '21 17:11 sigzegv

Hi, thanks for the question. No, currently there's no way to do that, regardless of which mode you expand the snippet from. If there is a $0 tab stop, the cursor jumps to it, otherwise it jumps to the end of the snippet.

I can see you might need/want that feature if your snippet contains no editable tab stops, just variables/eval blocks. For example, I think it would be great for using snippets as file templates.

For normal usage, however, I don't know if that feature would be very useful, unless you explain what you want to achieve in a bit more detail.

dcampos avatar Nov 27 '21 23:11 dcampos

actually I still would like to use snippets with editable tabs stops, but after ending the snippet (like reaching $0), I would like to go back to normal mode. For example I use sql snippets, I use a plugin that is able to run them to see their result either if they are in some code, so I don't always want to stay in insert mode.

sigzegv avatar Nov 28 '21 23:11 sigzegv

There is now the SnippyFinished autocmd. The user can set up it like this to enter normal mode after ending the snippet:

autocmd User SnippyFinished call feedkeys("\<Esc>", 'n')

dcampos avatar Feb 01 '23 22:02 dcampos