I am using the AutoClose plugin in Vim. I would like to set the behaviour so that when I am in the state
while(i < N) {<cursor>}
then when (and only when) I press return, I get to:
while(i < N) {
<cursor>
}
This is the behaviour in Sublime Text.
There is a similar question here: Automatically insert a matching brace in Vim but there the user is looking to start a new line as soon as the opening brace is created. Also it doesn't seem to work correctly for me.
If I use that, or do set cindent
as suggested by @WoLpH the result is (as soon as I create the opening brace)
while(i < N) {
<cursor>
}
as in the second brace is indented and the cursor is indented by one space. My vimrc settings are:
filetype indent on
set ts=4
set sw=4
set et