Character Info in Textmate

One rather useful feature of vim is that you can pull up information about a character by positioning your cursor over it and hitting ga (get ASCII?). I quite miss this in textmate, so I created a small command to add to the Text bundle. This is “Character Info”, which I’ve assigned to ^⇧I. It takes the selection as input and the information comes back in a tooltip.

  #!/usr/bin/perl
  use strict;
  use warnings;
  use charnames qw( :full );
  binmode( STDIN, ':utf8' );
  foreach my $c (split //, do { local $/; <> }) {
      my $code = ord $c;
      my $name = charnames::viacode( $code ) || "unknown character";
      printf "U+%04X %s\n", $code, $name;
  }
  exit 0;

This is what it looks like.

Character Info in action

The only caveat is that it only works if you’re using UTF-8 for your files. But really, if not, why not?

Comments are Closed