0

This is similar to a previous question re: Ctrl-Z. The context is different though: I use a bash shell window, in which I am in insert mode. Hitting Ctrl+^ in this mode means that I probably meant to switch to my other buffer.

1

It should be very similar to the linked question:

inoremap <C-^> <Esc><C-^>

This just makes it so that if you type <C-^> in insert mode it goes to normal mode and does the command there instead.

See :help map-overview for more info.

0

Tumbler41 answer is partially incorrect. Use of <Esc> is discouraged in favor of <C-o>, so you should use this line instead:

imap <C-^> <C-o><C-^>

although both are fine in your case.

However, for the educational purposes let's consider this example from my old .vimrc:

map <F5> :nohl<CR>
imap <F5> <Esc><F5>

After pressing F5 two thing will happen beside turning off highlights:

  • you will exit insert mode
  • cursor moves to the left

Also notice, that pressing i to reenter insert mode doesn't move cursor back to the original position, so you need to press to get it back to where it was before. I personally found it incredibly annoying.

After changing my example to:

map <F5> :nohl<CR>
imap <F5> <C-o><F5>

all of those problems disappear.

You can read more about <C-o> on the wiki.

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.