I have a bunch of ugly code in vim: it's not indented consistently at all. TextMate has this wonderful "code cleanup" function... and I'm sure vim is just as powerful, I just don't know how to automatically clean up my entire file (putting consistent tabs, with consistent length, after curly braces...and then unindenting after every code block is the main thing I want).
Asked
Active
Viewed 166 times
0
-
1If you post some (1) current code with your (2) expected formatting and (3) how vm actually formats, that would be helpful. – BryanH Jun 09 '12 at 04:18
3 Answers
2
Have you tried gg=G in normal mode?

Gebb
- 6,371
- 3
- 44
- 56
-
2I'd love to try it on my own box to help you out, but I can't load PNGs into vim :( – BryanH Jun 09 '12 at 04:19
-
I have to admit, even though I use `=` myself, it doesn't always work perfectly – Shahbaz Jun 09 '12 at 19:00
0
In Vim, indentation is defined by filetype-specific scripts. The default JavaScript indent file is not very up to date and doesn't play very well with "modern" ways of writing JS (lots of nested objects, anonymous functions…). Try other indent files and see if it solves your issue.

romainl
- 186,200
- 21
- 280
- 313