Automatically insert a matching brace in Vim

前端 未结 18 2527
醉梦人生
醉梦人生 2020-12-13 05:23

I spend way too much time fumbling around because Vim doesn\'t handle closing braces like most IDEs do. Here\'s what I want to happen:

Type this:

         


        
18条回答
  •  醉梦人生
    2020-12-13 06:15

    Vim patch 7.4.849 added a binding to allow for cursor movements without restarting the undo sequence. Once updated to >= 7.4.849 then something like this works great.

    inoremap ( ()U
    

    Note that I grabbed that straight from the documentation included in the patch. Best simple solution for this feature yet.

    • commit for patch 7.4.849: https://github.com/vim/vim/commit/8b5f65a527c353b9942e362e719687c3a7592309
    • mailing list thread: http://vim.1045645.n5.nabble.com/Any-automatic-bracket-insertion-plugins-not-breaking-undo-td5723654.html

提交回复
热议问题