1Line of text.

2Line of text.

3Line of text.

4Line of text. 5Line of text.

6Line of text.

[blue_message] This information is geared toward individual programmers who do lots of things in lots of languages.

If you are someone who works with web sites and web apps using languages such as HTML, CSS, PHP, (probably lots of) JavaScript, jQuery, WordPress themes, WordPress plugins, SVG, other scripting languages such as AHK, and too many others to remember, this is for you.[/blue_message]

I’ve done a lot of programming over the years. I’ve used a lot of languages. But it’s just been lately that I realized that I still spend too much time looking for the proper syntax to use, or the best way to code something in a language that I haven’t used in a while.

I’ve got lots of code that I can refer back to. The problem is that it really can take long time to find an example of how I did the code in the past. This is caused by the same reason I don’t remember exactly how to do the code in the first place. If you can’t remember how to code it, you also usually don’t remember exactly where you used it in the past.

Why not use some type of snippet manager program?

So I began thinking that it’s finally time to find some type of desktop based snippet manager where I can start over and collect all these bits and pieces of code and then my problem will be solved in the future.

Off I go on my search on the Internet for an open source snippet manager. Without a great deal of looking I did find a couple that I’m looking at now.

Snippet Manager Alessandro Cocco: jCodeCollector

And then here are some good online sources of code snippets: CodeKeep : Browse Code Snippets

How I Managed in the Past

I shouldn’t say I didn’t have a system for keeping and using snippets in the past. One of my all time favorites is a great little utility programs called AutoHotKey or, as more affectionately known, AHK.

Here’s their link: AutoHotkey. It’s free. If you don’t have it, get it. You can’t live without it.

It’s a wonderful fully mature and very well supported scripting language that you can use to do a hundred different things. I just looked and the AHK file I load first every time I reboot my computer is 2100 lines long. Full of useful stuff, especially code snippets.

[feature_box title=”Who does this apply to?” title_color=”fff” header_color=”369″] This information is geared toward individual programmers who do lots of things in lots of languages.

If you are someone who works with web sites and web apps using languages such as HTML, CSS, PHP, (probably lots of) JavaScript, jQuery, WordPress themes, WordPress plugins, SVG, other scripting languages such as AHK, and too many others to remember, this is for you. [/feature_box] But it’s not a ‘snippet management’ system. But one of the things it’s really good at is hotkey text replacement or expansion. A common use by people is for writing text and emails. You assign a larger or longer block of text to a smaller group of keystrokes. Then when you type the hotkey combination it is replaced by the larger block of text.

I use this a lot for code snippets. Especially for the shortcode combinations in the WordPress plugins I write. (I just used it now as a matter of fact. One of the hotkey combinations I put in my main AKK file is wpp. When I type those three characters, as I did in the last sentence, AHK automatically replaced them with ‘WordPress’.

It doesn’t seem like a lot does it? But I bet I type WordPress anywhere from 20 to 50 times a day. And it’s a goofy word to type correctly since you always have to remember the capital ‘P’ if you want to be politically correct. I still smile to myself some times when I type in ‘wpp’ and ‘WordPress’ magically appears. Just saved myself from having to do that capital P again.

But I digress.

Do You Need a Manager for Code Snippets or Text Snippets or Both?

After I had spent a little time with the two code snippet managers, I was a little disappointed. They are both great for managing and naming snippets of code. But, in the back of my mind I kept wishing that they worked more like my old AHK. I wished that I could assign a little hotkey combination to each snippet and then just type the code in my editor and the snippet would appear.

What I needed was a program that combined the hotkey features of AHK with the hierarchical storage, search and management system used so well by the code snippet management programs.

Then I remembered another hotkey program that I had looked at in the past. It’s called PhraseExpress. They describe it as aa ‘Autotext, Clipboard Utility and Snippets Organizer’.

I passed on it when I looked at it a few years ago because it didn’t have the programming power of AHK. But I remembered that it had a built in tree-view structure for organizing text (or code) snippets.

Screen shot of Phrase Express tree view

In their latest version I see that they’ve added some new features for handling the tree that stores the snippets. That will make it easy save and retrieve them easily.

After using PhraseExpress for a while I’m fairly happy with the way it works to handle my needs for code snippet management. On my ‘did I find what I was looking for’ scale of 10, I’d give it an 8. Or maybe an 8.5.

After you’ve put the snippet into PhraseExpress, it is truly nice to be able to quickly find the code and paste it into your editor.

Here’s how it works. When your working in any code editor you just leave your cursor at the point where you want the snippet to be inserted. Then right click on the PhraseExpress icon in Windows system tray.

A hierarchical tree menu pops up showing the first level of the tree where you have saved your code. I name the first level by the language, so I just hover over the language I want and the second level pops open. No clicking. It’s nice, smooth and quick.

Then I either pick the snippet I want or hover over another submenu level if that’s how I saved the snippets. When you see the snippet you want you simply click on it and it is automatically inserted into your editor. Very slick!

It takes ten times longer to read how it’s done that it does to actually do it.

Leave a Comment