jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.11k stars 373 forks source link

Too big indentation on putting a new line after e.g. ({ <CR> }) #54

Closed pmalek closed 11 years ago

pmalek commented 11 years ago

I have noticed that with your plugin using Insert new indented line after Return in e.g. ({ | }) I would get wrong indentation level.

mydata.forEach(function(d){
  d.interval = +d.interval;
  })

How this can be corrected or adjusted to produce something like this :

mydata.forEach(function(d){
  d.interval = +d.interval;
})

??

jiangmiao commented 11 years ago

It runs \<ESC>=ko when press <CR> after {. It is at 369 line of auto-pairs.vim, you could modify it by yourself. Or you could try better javascript indent plugin https://github.com/jiangmiao/simple-javascript-indenter

pmalek commented 11 years ago

Can you elaborate a bit on how to do this?

halftan commented 11 years ago

@malekp Well, I guess that wrong indentation is caused by your syntax or tabstop settings. Since it runs ko, which means move one line up[k], followed by edit in a new line[o], it's very clear that vim's indent mechanism is responsible for the wrong indentation.

pmalek commented 11 years ago

Ok I have solved this and now my 369 line looks like this :

return "\<ESC><<ko".cmd
mbrevda commented 10 years ago

For anyone still having this issue: I resolved this issue by following: http://stackoverflow.com/a/620310/747749

reidcooper commented 6 years ago

@mbrevda <3