Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When using vi, you can exit insert mode with Ctrl + C instead of the more traditional Esc. Are there any situations where it would be undesirable to use for former instead of the latter? Does it break anything other than best practice?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

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).

share|improve this answer
    
Good to know, but my question was about exiting insert mode. –  MDMarra Nov 2 '12 at 13:52
    
@MDMarra Doh, misread your question. Insert mode is still different: see updated answer. –  jw013 Nov 2 '12 at 13:54
add comment

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.

share|improve this answer
2  
Can you point to any vi implementation that still exists today that doesn't handle Ctrl-C? See my answer for the real difference. –  jw013 Nov 2 '12 at 13:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.