Posts RSS Comments RSS 32 Posts and 1,017 Comments till now

Archive for the 'TextMate' Category

Minor ProjectPlus Update

Just a bug-fix. More to come as I get time.

Get it here, or wait for Sparkle to update it for you.

ProjectPlus Update

Release notes:

  • Sidebar

    • TextMate does not load plug-ins until after the application is finished launching, which was causing problems when launching by double-clicking a project file (the project would open without a drawer or pane). This is now handled gracefully, but projects opened in this way will always have the drawer as they are opened before ProjectPlus is loaded.
  • SCM Badges

    • Added support for Mercurial, Svk and Bazaar (these should be considered experimental – I don’t use them so please report issues)
    • Hopefully more to come, based on demand and how easy they are to implement
    • Since there are now quite a few, and some of them are expensive to have enabled (as all except SVN use shell execution), all of the SCM modules are disabled by default and you must selectively enable the ones you want
    • Fixed a memory leak that could occur when using SVN badging
    • Misc. performance improvements and bugfixes
  • General:

    • Added Sparkle for automatic updates to future versions
    • Added an icon (thanks to Oliver Busch)
    • Other miscellaneous tweaks and improvements

Download.

Please report any issues you find at the new bug tracker.

TextMate Plug-in: ProjectPlus

I put this plug-in together some time ago and never released it; I just recently returned to it to while doing the SVN 1.5 update, added some more features and fixed some bugs, and I’m going to put this up as a beta release now. Mostly it’s a compilation of some of my other plug-ins, plus some miscellaneous new features.

Feature list:

  • SCM status badges:

    • Support for SVN and Git
    • Displayed in the project file list and the window proxy icon
  • Swapping the project drawer for a panel

    • Support for ⌃⌥⌘D and ⌃⌘R is kept
    • The sidebar can be placed on either side of the window
    • Since I created this someone has updated the MissingDrawer plug-in with these features, if you wish to use this plug-in instead then you can disable the feature
  • Finder colour labels

    • Labelled files are displayed in the project drawer
    • Label can be set through the context menu
  • Project-tree state can be preserved when re-opening the project

  • QuickLook preview of files in the project file list through the context menu (or ⌥␣ when the file list is focused)
  • Sorting options through the project file list context menu
  • Display folders on top
  • Sort by file extension
  • “Open With” option

You should remove any conflicting plug-ins before installing, by deleting them from ~/Library/Application Support/TextMate/PlugIns.

Download ProjectPlus.

SVNMate Update for Subversion 1.5

Well, after a long night of hacking I’ve finally got this up and running. I’ve used the libraries in a different way to the previous version which will make the whole update process easier in future.

Get it here

TextMate Plug-in – Find and Replace History Keyboard Navigation

Someone recently asked for a plug-in to navigate the find/replace history with the keyboard. After installing it you can use ⌃↑/ to move to the next/previous value.

TextMate Tip – Using PHP for Commands

Not many people realise that all the commands given to you by TextMate are written as simple scripts, editable by anyone, and in any language. PHP is a widespread language, but not many people are accustomed to using PHP for writing shell scripts, so they don’t know how to start writing a command – here I’ll explain how.

Continue Reading »

TextMate Tip – The Ruby Bundle

Today’s tip is a look at the Ruby bundle, which the bundle maintainer James Edward Gray II has kindly agreed to guest write. Take it away, James!

The Ruby bundle is a large collection of automations that will help you write and run Ruby code. If you are a Rails user, switch the language menu at the bottom of each editor window to "Ruby on Rails" to gain access to these automations plus those defined in the Rails bundle.

Writing Ruby Code

The Ruby bundle includes a large collection of snippet that simplify day to day coding in the language. At first glance through the menus, this may seem like an overwhelming amount of information to try and become familiar with. The truth is though that there are patterns to the snippets so that you can access what you need without having to memorize a bunch of triggers. The main things you need to know are:

  • Snippet triggers for Ruby's flow control keywords are just the full name of the first keyword used: if, case, while, etc.
  • Other snippet triggers are usually the first three letters of the first word in the code you want, plus the first letter of any additional words. That means you can use cla to bring up a menu of Class definition snippets, sor to get the sort() iterator, or sorb for sort_by().
  • There are exception to the rule, mainly when the shortcuts can be made to read better. For example, the triggers for attr_reader(), attr_writer(), and attr_accessor() are r, w, and rw respectively. You also get the each() iterator with the common abbreviation ea, which means you would use eal for each_line() or eawi for each_with_index().
  • Some snippets are based on fictional method names like map_with_index(), deep_copy(), or application_code(). These functional names tend to be easier to recall than the actual idioms they represent.

If this is the first time you are hearing of these mnemonics, practice a bit with my examples above to become familiar with them and then take a fresh look through the Ruby bundle menu. I suspect you will be surprised by how much you can retain without stressing your memory.

Don't be too surprised if some of the triggers are smarter than you expect. Some of them will add requires to your document (unless they are already present) to make sure needed libraries are available. If you want to bypass this feature for any reason, just tack an extra - onto the end of the trigger.

The bundle also contains several commands that can be useful in writing Ruby code. Here are two examples I use every day:

  • All of the iterator snippets insert a block using the braces syntax, but you can quickly get to the do/end variation by tabbing into the body of the block and triggering the "Toggle 'do … end' / '{ … }'" command (it's on ⌃{ by default).
  • Rails fans will appreciate the "Insert ERb's <% .. %> or <%= .. %>" command (on ⌃&gt; by default). You actually use this tool in HTML files even though it's defined in the Ruby bundle, since that's by far the most common usage of ERb. Trigger it once to insert the tags or repeat the keystroke to cycle through the variations.

Finally, if you are addicted to Ruby, you may just enjoy the possibility to use a little of it when writing any TextMate document. The "Execute Line / Selection as Ruby" command (on ⌃⇧E by default) will hand-off any content you can select to the Ruby interpreter and replace the selection with the results of evaluating that Ruby expression. Aside from the neat possibilities of being able to generate code, or any other content for that matter, with code, this makes for a darn handy calculator at times.

Running Ruby Code

As soon as you have some Ruby code, you are going to want TextMate to run it for you. The Ruby bundle offers several ways to do that:

  • The "Run" command (on ⌘R by default) will run the code currently in the editor window in the RubyMate environment. This command has a lot of advantages over going to the command-line: output is shown in an HTML window with the standard TextMate styling; exceptions are captured by TextMate and formatted to stand out; Test::Unit files are recognized and receive a modified path that helps them locate other files; test failures and errors are hyperlinked back to the code in TextMate; and STDIN is modified to prompt with a GUI dialog when a line of input is required.
  • While you can handle full test files with the above, the "Run Focused Unit Test" command (on ⇧⌘R by default) will run just the test method your caret is currently inside of. This can be quite a time saver for spot-checking changes.
  • Another tool definitely worth knowing is the "Execute and Update '# =>' Markers" command (on ⌃⇧⌘E by default). To use it, add some comment markers (there is a snippet on # that will insert these for you) to the end of lines you would like to see the results of and then trigger the command. TextMate will run your code and report the result of the marked line inline in the comments. This feature is great for code posted online since it shows the source and the results together.

There's more inside the Ruby bundle, but I've tried to hit the highlights that any Rubyist can probably benefit from knowing. You can get a lot of mileage out of knowing just this much.

Thanks a lot to James for writing this post, I hope you learned something. If you’ve still got a craving for more TextMate learning, James is also the author of TextMate: Power Editing for the Mac, which explains all about the robot ninjas hidden under TextMate’s shell and how to bend them to your will.

TextMate Tip – The HTML Bundle

I’m going to kick off a look at some of the bundles with an overview of the HTML bundle.

Continue Reading »

TextMate Tip – Macros

I’ve not posted for far too long as I’ve been busy with the holidays, starting a new job and working on a project, so apologies for the downtime, but hopefully this marks the return of regular posting. I’ll also try to work through all the comments as I’m a bit behind, so if I’ve not replied to you then apologies again.

Today I’m going to give some information about using Macros. Macros are simply a set of actions which you can record and then play back whenever you like. Most actions, including text editing, find and replace, clipboard usage, commands and snippets will be recorded, but there are some which are not (switching files and moving to a symbol for example).

Continue Reading »

SVNMate Update

This just fixes a memory leak that could occur when using projects which weren’t under Subversion control. I’d recommend that everyone update to the new version.

Next »

Fork me on GitHub