Thursday, June 16, 2011

The Source Code Tool Belt

As the cast of Home Improvement was heard to say, “What time is it?  TOOL TIME!”
probably violating some copyrights
Every profession has its tools of the trade.  Country doctors have the little black bag.   Cable guys bring Velcro totes with crimpers and punchdown tools.   The Maytag Repairman brings – nothing.  Anyway, don’t you wish you had tools like Handy Mandy, those talking tools that do the work themselves? Or wonder how to get Kevin Smith’s Mallrats character Silent Bob’s utility belt with grapplers or lassos, “Bigitty Bong”?  We’re talking about the right tool for the right job.   Here are some tools you can confidently hang on your source code tool belt.

For text editing, you can use the Windows Notepad by pressing the Windows© Key and the letter ‘R’, then typing “notepad”; or you can use other text editors, such as Programmer’s Notepad, Notepad2, and Notepad ++.   In a post earlier this year I listed Notepad++ as one of my favorite tools.  I use Notepad++ as my text editor for several reasons:  it handles multiple documents; it displays line numbers, which is valuable in writing code; and, with syntax support for just about every popular programming language from ADA to YAML, Notepad++ is just short of Visual Studio’s IntelliSense© in its ability to detect keywords and operators.

Notepad++ configured in Obsidian Style
How can you use Notepad++ instead of the default MS Notepad?   There are several techniques in doing this and you can search them online, however, here’s my preferred technique:
1. After installing Notepad++, go to the Notepad++ directory (C:\Program Files\Notepad++).
2. Copy the Notepad++.exe file and paste a copy of it in the same location.  This copied file will be “C:\Program Files\Notepad++ - Copy.exe”.
3. Rename the copied file “C:\Program Files\Notepad++ - Copy.exe” to “npp.exe”.
4. Go to your System Environment Variables:

  • Right click on “My Computer”
  • Click on Properties, Advanced, System Settings, Environment Variables
  • Under “System Variables”, choose “Path”, then click Edit
  • Go to the end of the Variable Value and type a semi-colon “;” followed by the Notepad++ path (C:\Program Files\Notepad++).
  • Click OK.
5. Open the run command, type “npp”, and press Enter.
6. Notepad++ should start.

If you’re like me, you probably have a mish mash of code samples dating back to when you first learned to write a User Defined Function in SQL, or created your first class in C++.   These code snippets might be saved in text files or even .vbs, .js, .cpp or .sql files. When it comes time to share or reuse that code, it’s a pickle of a problem to find it.  I will be the first to admit that I don’t have my code samples organized 100% of the time.
Here’s a great utility for this problem:  It’s called Windows Grep, and it searches content within files   (for you computer trivia collectors, the word “grep” was originally a Unix command meaning “global regular expression print “).  If I want to share a snippet of code that I know I wrote and saved as a .vb file, I use Grep to find this for me.  For instance, I can enter the word “Loop”, select my path “E:” drive, and search for all VB files, “ *.vb”.   Grep will then return any VB files with a Loop in the content.   

If you want a more organized method to search for code, use Evernote to organize your code snippets. Evernote is a great note taker that will synchronize your files online for all devices listed under your account.  “How is a note taker useful with source code?” you may ask.  For one, it saves your files online.  Also, you can categorize your code in Notebooks by language, i.e., JavaScript, Batch, C#, SQL and so on.  Each file can be tagged with specific keywords, for instance “Adapters”, ”Mouseovers”, or “TableValueParameters”.  This makes finding code easier.  You can select a Notebook of language like C# and narrow down the C# snippets to only show you code with “Adapters”. To add your current collection of snippets to Evernote, it’s easy:
Evernote view of my C# Notebook
1. Install Evernote
2. Go to Tools, Import Folders
3. Begin Organizing files into Categories and Tags

Notepad++, Grep, and Evernote already make a powerful source code toolbelt.  I might be leaving out ExamDiff, the free, easy to use code comparison tool with a few remembering capabilities, navigation and command options, and the ability to detect live changes.  I might also be leaving out the “new to me” CodeRush Xpress, Visual Studio plugin with features for navigation, refactoring, and much more. 
So, get out your laptop or toolbox of choice and put these freely available tools in there.  You’ll then be well equipped to master your source code.


  1. A better way to replace notepad is using "Notepad Replacer". It will run your NP++ anywhere where notepad was used by default. It supports other editors as well.

  2. That is a good utility, I will look into it, but it seems I might not need to if I already configured it in the Environment Variables.