Tag Archives: tips

The Scary Programming (Variable Names)

terror

Ranting is not my favorite way to express, I’m more like a constructive guy. But also, the blog is a reflection of what I’m doing right now. And for the title of the post you can guess I’m not doing a lot of GIS.

Lately I’ve been spending my time reading some questionable code, which made me think about the habits of programming. There’s no exact science here, but it is true that bad handled code can explode really fast creating a series of problems.

  • Maintenance hells.
  • A bug fixed, uncovers another bug.
  • Hard to get somebody up to speed.
  • Lots of snorting (iup that’s me).
  • Clear increase of gray hair (iup, that’s me).

I started drafting a post about this topic. Then, it exploded in size. So I decided to split it in digestible bits of enjoyment.

The original title was: The Code Apocalypse but I settled for something milder because… that’s my style :-D.

Variable Names

Advertisements

Leave a comment

Filed under code, tips, TSP

Trailing Whitespaces Vim

Trailing whitespaces are a pain in the ass. Adding, deleting and modifying code can lead to invisible spaces at the end of the line. This is “bad” and useless.

Here comes Vim!
:%s/\s\+$//

A substitution command :%s/<search>/<substitute>/
Where the search is for trailing whitespaces \s\+$ and the substitute is “nothing”.

Writing this every time is too much effort, it’s a good idea to define a user command:
:command Deltw :%s/\s\+$//

Or better, add the line to your vimrc file:
command Deltw :%s/\s\+$//

now just typing the command Deltw deletes those annoyances.


References

Vim patterns ⇒GO
Vim user_commands manual ⇒GO

Leave a comment

Filed under tips, vim