What is the difference between and in vim?

前端 未结 3 807
刺人心
刺人心 2020-12-14 20:58

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 Es

相关标签:
3条回答
  • 2020-12-14 21:14

    Extremely late answer, but I just had the same question and found one practical example which helps explain the difference, so why not.

    If you select a visual block and then change it with c or append something to the end of it with A, if you then exit with <Esc>, the same change will happen on all the lines of the visual block (which is really useful! See :help v_b_A); if you exit with <C-c>, this doesn't happen, only one line gets the change. There are probably other similar things I didn't realize I was missing with <C-c>...

    0 讨论(0)
  • 2020-12-14 21:16

    As it turns out, <C-[> is exactly identical to Esc, they are the same character. So no need to wonder about any difference there. :)

    0 讨论(0)
  • 2020-12-14 21:25

    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>
    
    0 讨论(0)
提交回复
热议问题