Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to indent multiple files which are poorly indented and indent them properly as would vim do when I type gg=G. Is there someway to enter the = command or its alias in the command mode? i.e after a :? If that is possible I can use the bufdo command like in this question.

share|improve this question
up vote 5 down vote accepted

You can run any normal command with :normal, e.g. :normal =G.

If the files are C source code, it may be easier to use the external program indent.

share|improve this answer
I recomment astyle over indent. – Martin Ueding Jun 10 '11 at 13:19

Not sure how to do it with vim, but should be possible.

You may also try the command "indent", it should do what you want, although not with the indentation you have configured in vim.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.