Monthly Archives: February 2014

Finally trying a text expander

Being a code monkey, I can type pretty fast. More importantly, I can type naturally, just expressing my thoughts without thinking so much about where my fingers go. It’s the same as when you get good enough at driving that you don’t think about turning the wheel or pushing pedals, you just drive. Martial artists develop the same union with weaponry; the sword becomes an extension of themselves, connected to their center and not a separate entity.

Anyway … I’ve gotten to the point where I prefer to retype something than to try to save keystrokes by retrieving it from, say, my shell history, or by copying and pasting. It interrupts the flow, makes me think about the tool again. By the time I’d mentally work out the “more efficient” method, I could just have retyped it, wasting keystrokes but staying in the flow.

I use a set of software to help keep me flowing and efficient, stuff like Quicksilver and Fluid. But I haven’t used another time saver, a text expander, until the past couple of weeks. A text expander watches what you type and replaces it on the fly, so you can just type “tyvm” and presto, it turns into “thank you very much”. Sounds like a no-brainer to add to my toolset, but I was reluctant to bother since I could just type instead.

So what changed? I think it has been working on Accumulo. That is a tough word to type. Even after these few months with it, it can still tangle my fingers. So, after consulting Lifehacker I gave aText a shot. So, now when I type “accm” I get “accumulo” substituted. “Accm” becomes “Accumulo” and “ACCM” becomes “ACCUMULO”. Yes, I need all three cases. As a bonus, I configured it to make a satisfying pop whenever it expands. a-c-c-m *pop*

Just yesterday I added “SNPS” for SNAPSHOT, since I work with Maven all the time. I suppose that now that I have the tool on hand I’ll start to notice more and more places where it makes sense to use it. I intend to use it only in narrow circumstances, and rely on more traditional – and portable – shortcuts like shell aliases and code editor snippets (ah, Sublime Text) for the majority of cases.

There’s an art to defining expansions. Your abbreviated form has to be something unique and unambiguous, or else you’ll get the expansion when you don’t want it. If I just used “acc” for “accumulo”, I couldn’t write “accept” or “accelerate”.

There is still the extra thought involved right now, remembering that I have the option to type less. Still, I can just write the words out and not worry about it. With time and practice, I expect that I’ll remember to use the tool more often, and the mental speed bump will fade away.

One thing I worry about is that I’ll get too used to the tool, and when I’m on a machine without it, I’ll have to un-remember to use it, and work through another mental speed bump. We’ll see if that becomes an issue. For now, I’ve ponied up the five bucks and added it to the family.

Programming Font: Droid Sans Mono

I have to admit that I like fonts. I’m one of those oddballs who knows about serifs and x-heights and descenders and kerning and autoligatures and all those sorts of things. I’ve never designed my own font, but I know what I like, and since I spent a lot of time coding and staring at terminals, I definitely know what I like to use for those purposes. Over the years I’ve had different font preferences, and I’d like to periodically post about some that I like now or used to like.

The first one on my list is what I use for my iTerm2 window: Droid Sans Mono.

Droid Sans Mono specimen

Droid Sans Mono specimen from

It doesn’t have as many sharp corners as other popular monospaced fonts, and the letter spacing is also much bigger, which helps keep commands from running together at the prompt. The lowercase letters are nice and big compared to the capital letters (that is, the font has a nice, big x-height), which makes for easier reading at smaller sizes (which I avoid anyway, my vision is bad enough already.)

Sublime Text – enabling Eclipse code formatting

My editor of choice for the longest time was emacs, but recently I’ve made the switch to Sublime Text. It’s such a snappy, beautiful, powerful editor. I’ll still use emacs (or vi even, yecch) over a text-only connection, but otherwise, Sublime Text is the bomb.

Sublime Text isn’t an IDE, however; it’s only an editor, and so is missing some bits and pieces that folks used to Eclipse or Netbeans like to have. It makes up for it by being extremely extensible and customizable, using only Python and JSON.

Sublime Text does perform code formatting for you, but most of the world has standardized on using Eclipse for such work. Such is the case for the Apache Accumulo project, which requires code to adhere to formatting rules saved off in an Eclipse-specific XML file. If you are working under Eclipse, this is just fine, and there is even an IntelliJ plugin; otherwise, well, you may have to bounce into Eclipse just to format code. Fortunately, there is an EclipseCodeFormatter plugin that can call out to Eclipse from Sublime Text to format for you.

The easiest way to install the plugin is to first grab Package Control, which is like yum or apt for Sublime Text. Then, use Package Control to install EclipseCodeFormatter.

You do need to manually configure the plugin, as described on its home page (linked above). In order to do it, you will have to up and install Eclipse. Once you do, you can immediately enter the path to the eclipse executable in the plugin configuration. On a Mac (what I use), the configuration file for the plugin is under ~/Library/Application Support/Sublime Text 2/Packages/EclipseCodeFormatter; the patch to Eclipse is something like /Applications/eclipse/eclipse (actually a symlink to inside the .app).

"eclipse_command": "/Applications/eclipse/eclipse",

To create the configuration file the plugin needs, start up Eclipse and create a new Java project. Maybe make a new Java file in there for kicks. Now, go under Preferences → Java Code Style. Under Formatter, follow the link “Configure Project Specific Settings” and enable specific settings for your project. Select the profile you want to use in Sublime Text. (You can also import an XML file if you have it, like Accumulo provides.)

Now do the same thing for Code Templates if you have specific settings for those too. Now, in your project workspace, under the .settings directory, there should be a file “org.eclipse.jdt.core.prefs” file chock full of formatting instructions. Copy that somewhere where you’d like it to live (I put it right with the plugin files). Now you can configure the plugin’s path to the config file to point to that file.

"config_file": "/Users/bhavanki/Library/Application Support/Sublime Text 2/Packages/EclipseJavaFormatter/org.eclipse.jdt.core.prefs",

You’re all set to use the plugin. You can use the Command Palette to invoke the command and format the current buffer. You can also add a keymap entry to turn on a shortcut for it. Under Mac OS X, I found that Control+Shift+F was available:

{ "keys": ["ctrl+shift+f"], "command": "eclipse_format_java" }