i've got a mapping for iterating thru suggested pop up window of omni completion

inoremap <expr> <TAB> pumvisible() ? "\<C-y>" : "\<TAB>"

but i also want a to trigger while there is no suggestions menu but a snipmate shortcut <Plug>snipMateNextOrTrigger has been faced, but now only actual tab is inserted after an expression expected to be expanded.


inoremap <expr> <TAB> pumvisible() ? "\<C-y>" : "<c-r>=snipMate#TriggerSnippet()<cr>"

One way would be to call whatever <tab> is normally calling instead of issuing the tab key press. Something like:

inoremap <expr> <TAB> pumvisible() ? "\<C-y>" : "<esc>:call NormalTabFunction()<cr>a"

The command that actually worked in this specific case was (resulting from the discussion in the comments):

inoremap <expr> <TAB> pumvisible() ? "\<C-y>" : <c-r>=snipMate#TriggerSnippet()<cr>"
  • Could there be a slash missed, cuz it inserts a text :call NormalTabFunction() literally?
    – Dmitrii
    Mar 21 '17 at 13:56
  • Sorry, missed the fact that this is an insert mode mapping. I changed the answer to include <esc> and a to get out of and into insert mode. This should work with a minor side effect: if the cursor is in front of the first character on the line, the cursor will move one space right. Since you're using this for completing, I'm not sure whether that matters.
    – Octaviour
    Mar 21 '17 at 14:22
  • error: Unknown function: NormalTabFunction()
    – Dmitrii
    Mar 21 '17 at 14:25
  • With NormalTabFunction I mean the function that normally gets called when tab is pressed, sorry for being unclear about that. You might find this function by running :imap <tab>.
    – Octaviour
    Mar 21 '17 at 14:28
  • it's <Plug>snipMateNextOrTrigger() if i insert it as is it says that function name required, if i specify it as snipMateNextOrTrigger() it says that unknown function, should i escape <Plug> in some way or smth else?
    – Dmitrii
    Mar 21 '17 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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