cosmogonies.net Blog of cosmogonies.net

14Feb/130

Invisible chars could be a nightmare

... so avoid them at all costs. Show these shy bastards !

The main trick about whitespaces is about not being able to see them, or count them.

Because you could fail an == operator due to these discreet ghosts,
or also badly concatenate paths or batch commands,
please always configure your IDE to show whitespaces and co.

  • Tabs too !

Especially dealing with python, I found very usefull to display an arrow (Eclipse, NotePad++) or a line (Sublime) to easily count the level of indentation.
But it happens sometimes you have to merge foreign code, from others snippets, from internet, from samples in doc of your Maya/MotionBuilder/whatever, and you will have to conform everything.
So let's make a rule of showing every tabs as whitespaces (4) and display whitespaces.

  • my IDE Configuration reminders.
  1. Eclipse: Window > Preferences > General > Editors > Text EditorsĀ  "whitespace characters"
  2. Sublime: on file Preferences.sublime-settings
    "draw_white_space": "all",
    "tab_size": 4,
    "translate_tabs_to_spaces": true,
  3. MonoDevelop: Tools>Options: Text Editor>Markers and Rulers "Whitespace Markers"
  • Log it right!

    When displaying a variable, for a quick debug of a value, I prefer to always finish by an equal without spaces like that:

    print("MyVar ="+str(MyVar))

    It's a not nice to read, but displaying like that you will have a real certitude about the start of the value. Just after the marker "=". You cannot be more sure.

  • End of the line...

At last, I do not show EndOfTheLine carret. Because they are blurrying the view, especially from braces opening.
And I never encounter a case where it is helpful to display. Please sure if you have !

 

partner
Tagged as: , No Comments
trademarks
   
noticepartner
faq