Sunday, June 14, 2015

Re: expanding a (g)vim snippet from menu

On Saturday, June 13, 2015 at 8:22:01 PM UTC+12, Rudra Banerjee wrote:
> an Snippet<Tab>`prg :execute 'imap `prg prg' . :UltiSnipsExpandTrigger . '<Esc>gg=G<C-j>'

Your problem is being caused by the Esc and NL characters; they are causing the execute to finish early. I'm not sure whether they should, but this hinted at a solution.

As well, I get

E331: Must not add menu items directly to menu bar

if I use your menu command, and it should have <cr> on the end.

Breaking up the <Esc> and <C-J> to delay their evaluation seems to work:

an My.Snippet<Tab>`prg :execute 'imap `prg prg' . g:UltiSnipsExpandTrigger.'<E
sc'.'>gg=G<C'.'-j>'<cr>

I say it "seems to work" because the output of imap appears as desired; I don't have UltiSnips so I haven't invoked the mapping.

When selected off the menu, this gives an annoying "Press Enter or type command to continue" prompt, because the execute is so long. It can be ignored, or see :help hit-enter
for a discussion. If g:UltiSnipsExpandTrigger doesn't change much you could copy it to a shorter variable I suppose.

Regards, John Little

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment