Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between <C-C> and <C-[> in vim?

Tags:

vim

One of the best tips for using vim that I have learned so far has been that one can press Ctrl+C or Ctrl+[ instead of the Esc key. However I use a dvorak keyboard so Ctrl+[ is a little out of reach for me as well so I mostly use Ctrl+C. Now I've read somewhere that these two key combinations don't actually have exactly the same behaviour and that it is better to use Ctrl+[. I haven't come across any problems so far though so I'd like to know what exactly is the difference between the two?

like image 460
user13060 Avatar asked Sep 17 '08 07:09

user13060


People also ask

What is CC in Vim?

C replaces the rest of the line (starting at cursor position) with your edit. cc and S are synonyms and replace the whole line(s) with your edit.

What does Ctrl C do in Vim?

CTRL-C : Quit insert mode, go back to Normal mode. Do not check for abbreviations. Does not trigger the InsertLeave autocommand event. Another difference happens when you enter Insert mode with a count, in which case CTRL + C will cancel the repetition from the count.

What does CW command do?

The cw command produces distinctive output when used with the Times Roman font. The CW font contains a nonstandard set of characters. Any text typeset with this font requires different character and interword spacing from that used for standard fonts.


1 Answers

According to Vim's documentation, Ctrl+C does not check for abbreviations and does not trigger the InsertLeave autocommand event while Ctrl+[ does.

One option is to use the following to remap Ctrl+C

inoremap <C-c> <Esc><Esc>
like image 119
jeannicolas Avatar answered Oct 24 '22 13:10

jeannicolas