📜 ⬆️ ⬇️

About Trailing Weightspace Say A Word

It means so. By the power given to me by a habra editor, I declare this topic a place of righteous anger, rage, a place of universal grief and impotent hatred that arise in noble men at the sight of such a picture:

image

And now SUDDENLY, without any razmusolivany, the two oldest, as the world, truth. Do not say that you have never heard of this. And the more so do not say that you need arguments. Art arguments - for the faint of heart, the Truth of the Ancients does not need to be argued! [*]

Have pity on your colleagues, whom this garbage prevents from working. Do not produce the Augean stables, which your neighbor will later rake. Have a sense of self-worth in the end. Take 3 simple steps towards mutual understanding, peace and harmony.
')

Step 1: Acknowledge the problem


Stand in front of the mirror and, looking into your eyes, say: “In my code is full of these vile trailing wayspaces and constantly dispersed tabs. With this we need to do something. Need to solve this problem. I can no longer cause so much discomfort to all these guys who work with me. ” If it does not help, then try to speak this mantra several times.

Step 2: Turn on your White Space Detector in your editor


Customize your favorite editor so that it shows tabs and extra spaces. Virtually any serious editor can do this. If your editor doesn’t know such simple things, then immediately remove it — now it’s too simple for you — and install vim or emacs. Or Textmate. Or E Text Editor.

In Vim, the illumination is switched on very simply:
set list
set listchars=tab:»·
set listchars+=trail:·
set endofline


In emacs, there is a special whitespace module that allows you to highlight and (bingo!) Annihilate invisible reptiles with one command:
Mx whitespace-cleanup

Step 3: Block unclean path to your repository


Seriously. Contact the person who maintains your repository, and ask him to add a post-commit hook to check for pests. Write a script for any SCM is not difficult. By the way, it is quite possible that in your system, the function of detecting the whitespaces is already out of the box, for example, in git-e it only needs to be enabled.

[*] Future reading


Tabs considered harmful
Trailing whitespaces are bad

Source: https://habr.com/ru/post/77155/


All Articles