Does using ctrl+c instead of esc to exit insert mode break anything in vi?

Ctrl-C and Esc are not the same in vi/vim in most modes, including insert mode. The difference is Esc triggers abbreviations while Ctrl-c does not. Whether this matters to you depends on whether you or any plugins you use make use of abbreviations.


Note that it is safer to assume Esc and Ctrl-C do not mean the same thing in vim. Another example from this same site is when exiting block insert mode (not in vi).


I think you mean vim, not vi.

This does indeed work in vim, though I wouldn't use it unless I was 100% sure I would never touch a non-Linux operating system, ever. The reason is that other OSes may have their own implementations of vi, which do not implement this, and you might find that when running vi on those platforms, Ctrl-C has its own traditional behavior: interrupt the process and leave your terminal in a weird state.


If you're referring to vim, there is a slight difference. CTRL-C does not check for abbreviations, and it does not trigger the InsertLeave event. So you or plugins have defined any autocmd statements that depend on InsertLeave, they won't get triggered.

From the official documentation http://vimhelp.appspot.com/insert.txt.html :

<Esc> or CTRL-[ End insert or Replace mode, go back to Normal mode.  Finish
                abbreviation.

CTRL-C          Quit insert mode, go back to Normal mode.  Do not check for
                abbreviations.  Does not trigger the InsertLeave autocommand
                event.

You can define a mapping for CTRL-C to <esc>, then it will trigger InsertLeave.

Tags:

Vi

Vim