Set vim's equalprg for better formatting
One of vim's more useful features (sometimes) is the ability to format/indent code in the many syntax types it supports using = .
Of course, it's not always perfect. Sometimes there's a better tool for the job than vim's builtin behavior.
For times like this, you can set vim's equalprg property for the current buffer. It functions much like makeprg, in that it lets you specify an external command into which the selection (or buffer) will be piped and then replaced with the stdout of that command.
So for example, it's useful when editing xml to set equalprg to use xmllint:
set equalprg=xmllint\ --format\ -
Written by Spencer Williams
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#