Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic new line and indentation in vim when inside braces?

For example, if I'm coding jQuery in vim, and I have this in insert mode ("|" is the current cursor position):

$('#something').click(function(){|})

...and I hit enter, I would like to get this:

$('#something').click(function(){
    |
})

...while currently, I'm getting this:

$('#something').click(function(){
|})

The same thing happens with function definitions in PHP. Is there a way to automatically insert the extra new line and indent the cursor position when hitting enter inside braces like that?

(Apologies if this has been asked before - it seems like a common request but I searched for awhile and couldn't find it.)

like image 255
Mike Crittenden Avatar asked Jan 22 '11 13:01

Mike Crittenden


1 Answers

Just install auto-pairs plugin and be happy.

like image 102
anton maslakov Avatar answered Oct 27 '22 11:10

anton maslakov