0

I have following mapping

imap jj :execute 'tabnew'<cfile><CR>

instead of opening the under the cursor it just puts the string in place.

  • 1
    imap is an insert mode mapping. you probably want map. – Herb Wolfe Oct 5 '17 at 3:43
  • i especially want this to happen during insert mode – nikoss Oct 5 '17 at 4:11
2

You should use instead of So imap jj <C-\><C-O> :tabnew <cfile><CR>

  • Welcome to this site! Your answer is flagged as low quality, it would be nice to add an explanation of what <C-\><C-O> does and how it differs from the accepted answer: that would be more useful for future users reading your answer. – statox Jan 13 at 17:50
  • Source Ctrl-O switches to normal mode for one command, then switches back to insert mode so you can continue typing. – user1431578 Jan 14 at 19:07
1

I figured the issue out.

imap is actually doing exactly as it's told to do. It is going and pressing keys I typed there. So what I was missing to make it press before the command imap jj <ESC> :tabnew <cfile> <CR> works perfectly

  • @Rich thanks for pointing out I just forgot about this question and I just couldn't immediately accept my own question back then. – nikoss Nov 6 '17 at 22:24

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.