Home > Uncategorized > Pleasing the geek in me

Pleasing the geek in me

My interests are all over the charts. That should make blogging a breeze, since accordingly I should be interested all the time and have plenty to write about. But then there’s this notion of concentrating your blog around a theme, a thread…

You know what? Forget all that. For now anyway. Here’s a post on a geeky tech tip. It’s neither particularly advanced nor revolutionary, but oh so useful. It made my day and I’m sure it can and will make someone else’s too.

The tip: How to indent XML files in UltraEdit

I’m a long time Windows victim…sorry; user who has lately fallen in love with the Mac. I still use both though, both at home and at work. This tip is mostly a Windows one, but you can achieve the same with, for instance, Smultron on the Mac.

One of my favourite Windows applications is UltraEdit. It’s powerful and flexible, but most of all: Its power is available to me after years of (power) using it. There are lots of other great editors with rivaling or even superior power, but to make equal use of them I would have to learn to master them too.

doc_xml_icon_128x128Anyway: At work I view and edit tons of ugly XML files and for that I happily and successfully use UltraEdit. There has been one thing missing though: The ability to pretty print (i.e. indent) XML. I did make an attempt to install XMLValidator4UE, but it failed due to .NET framework issues, so I gave up and eventually installed Altova XMLSpy. That’s a great XML …eh… monster. You can do pretty much anything XML-ish, but that also soon became my issue with it; it’s basically too bloated for my use.

Enter HTML TIDY – a great little snappy app to aid you with cleaning up your markup. It has been living peacefully on my machine for quite some time now and sure – I’ve used it occasionaly, via the command line or through Notepad++’s TextFX HTML Tidy plugin. But I’m a friend of streamlining your tools and utilities. I don’t want to jump from tool to tool, certainly not for tasks I perform frequently.

Today I decided to make an effort to marry UltraEdit with Tidy. It was with great joy and ringing bells I discovered it was actually easy peasy. The key here is UltraEdit’s Tool Configuration. After that I just had to find out what parameters to feed my new little old friend. You can find them all on the Tidy Man pages, but in short these are the ones that did it for me:

-xml tells it that the input is an XML file
-i tells it to indent
-m tells it to modify the file in-place
%F is UE’s placeholder for the active file

Also, I had to specify the character encoding by adding the option -latin1 to tell Tidy to use the ISO-8859-1 character set to deal with all the ås and the äs and the ös (or as the Norwegians would say: The æs and the øs and the ås) </scandinavian_language_lesson>

I.e. tidy -xml -m -i -latin1 %F

Voilà! Press Ctrl-Shift-0 to indent the open file.

Caveat emptor: It’s not perfectly streamlined. …yet ;) I could improve it to dynamically load the correct charset. I could make it reload the file automagically (today I have to answer Yes to the “… has been changed by another application. Do you want to reload it?” message after indenting). I could… Hey, enough already – it’s working.

_geek_glasses_clearThe geek in me is pleased.


Tags:
  1. No comments yet.
  1. No trackbacks yet.