Reformat or fix the indentation of an entire file in vim

Tools:

  • 1 ea vim

1Set the indentation rules in your .vimrc

See details

2With the target file open in vim type

gg=G “=” is the indent command and it can takes motions. So “gg” means start at the beginning of the file and “G” means finish at the end.


Now learn about:


Discuss this guide

var disqus_shortname = ‘howchootest’; (function() { var dsq = document.createElement(‘script’); dsq.type = ‘text/javascript’; dsq.async = true; dsq.src = ‘//’ + disqus_shortname + ‘.disqus.com/embed.js’; (document.getElementsByTagName(‘head’)[0] || document.getElementsByTagName(‘body’)[0]).appendChild(dsq); })();

Tools:

  • 1 ea vim

Leave a Reply

Your email address will not be published. Required fields are marked *