0

In Eclipse, when I add a new line of code to an existing file, if i press 'Tab' key for indentation, Eclipse generates a leading whitespace.

enter image description here

In code review tool (Gerrit), those leading whitespaces get flagged.

So looking for a way to check for all the leading whitespaces before committing the changes to repository.

Using 'git-diff', is there any way to detect leading whitespaces for newly added code lines?

Xplora
  • 837
  • 3
  • 12
  • 24
  • 1
    You could pipe the output of `git diff` through something that converts tabs to something visible. [This question](http://stackoverflow.com/q/16692835/24874) covers that. – Drew Noakes May 05 '16 at 16:48
  • @DrewNoakes True but that solution seems bit lengthy. Actually, there is a way to highlight trailing whitespaces in 'git-diff' output (http://stackoverflow.com/questions/3920650/git-diff-show-me-line-ending-changes/11509629#11509629), so looking for similar solution for highlighting leading whitespaces. – Xplora May 05 '16 at 16:55
  • I agree it could be a nice feature. There is probably a way to do it within the bowels of git (maybe via a custom pager) but I am not confident of how to do that. You could alias `git-diff` or some other command to make it shorter. – Drew Noakes May 05 '16 at 18:39

0 Answers0