Automatic closing brackets for Vim [closed]

For those of us, who want a vanilla vim:

inoremap " ""<left>
inoremap ' ''<left>
inoremap ( ()<left>
inoremap [ []<left>
inoremap { {}<left>
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O

This autocomplete in insert mode, provided set paste is not set. Keep it in the vimrc to avoid typing it every time and when we don't want the mapping, we need to escape it using ctrl + v before typing the mapped char like ( { etc.


I've just tested ClosePairs, AutoClose, DelimitMate and AutoClose in Vim 7.4.131 on Ubuntu, using Pathogen.

Not surprisingly at all, all of them work.

Your question should be rephrased since you are not searching for "an auto closing plugin that works in 7.4"… because all of them do. What you should ask is "Here is my setup, how come none of the "auto closing" plugins work for me?".

A question one could answer with: "It's a mess. Start by commenting out everything before line 95."

Also, Vim is a very stable environment: "not being actively worked" on doesn't mean "not worth trying". Quite the contrary, actually.


Giving a vote for delimitMate before angry mods close the question for being opinion-based.


Adding a new candidate: there's a plugin called lexima. It was introduced in October 2014, so it's rather new. According to the author, it features high customizability and dot-repeatability. It can also be customized to auto-close def - end pairs as in ruby.

Here's the presentation by the author in the VimConf held in Japan, which compares different ways to achieve auto-closing functionalities.