I'm having a hard time figuring this out. I'm typing the following with the help of the AutoClose.vim plugin:
function trim() {|}
| is the position of my cursor. What I want to achieve is as soon as I hit enter the code should look like:
function trim() {
|
}
Instead, what happens now is:
function trim() {
|}
Try :set cindent
. This won't do precisely what you ask, since pressing Enter once only adds one newline, not two, but you should get something like:
function trim() {
|}
After you type the last line of your function, use Ctrl+D (in Insert mode) to "dedent" (opposite of indent) the }
back to the left margin.
You may need to also change the cinkeys
option to make sure that the autoindent reacts to the keys you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With