4

I have following mapping

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

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

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

2 Answers 2

4

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

2
  • 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
    Commented Jan 13, 2019 at 17:50
  • Source Ctrl-O switches to normal mode for one command, then switches back to insert mode so you can continue typing. Commented Jan 14, 2019 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

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

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.