So I’m using a tool to automatically indent after brackets in C files:
filetype plugin indent on
However, I also want to automatically close brackets, parens, and other code delimiters when I type the first part of them. To achieve this, I have added this to my vimrc:
inoremap ( ()<Left>
inoremap { {}<Left>
Now, however, when I press enter in between the two brackets that are created, my code is no longer automatically indented. If the automatic completion of brackets feature is disabled, it works fine, but I have to manually close my brackets. I have also tried using DelimiterMate to the same effect. Is there any way around this?
This Vim Tips Wiki page contains a full discussion of the topic, starting with simple mappings like yours. Because there are many corner cases and areas where it should just work, I recommend a plugin though. The mentioned page has a comprehensive list of plugins. (I occasionally use AutoClose by Karl Guertin.)