• Posted by Peter Haza
  • On August 9, 2008

  • Filed under TextMate

  • 3 Comments

TextMate tip: Go to first non-space character on current line

One small thing that has always bugged me with TextMate is that ⌘← goes to the beginning of the line, instead of what I prefer: the first non-space character on the line. Well, thanks to “Jacobolous” in ##textmate@irc.freenode.net, that’s not a problem anymore.

This command has been updated, you can read what was changed here.

You can now download the command here: Go To First Non-Whitespace Character

It’s actually very easy to sort out, and even though I’ve thought about fixing this before, I never managed to wrap my head around it. The whole solution is to record a macro, and it takes you about 40 seconds. The whole procedure is as follows in TextMate:

  • Press ⌥⌘M to start recording a macro
  • Press ⌘← to go to the beginning of the line
  • Press ⌘F and search for [^\s]|\n with regular expressions enabled (Thanks to Abhi Beckert)
  • Press ← to go to beginning of selection(unselecting)
  • Press ⌥⌘M to stop recording the macro.
  • Press ⌃⌘M to save your macro
  • Give the macro a name and a key equivalent (I used ⌘← to overwrite the normal go to beginning of line behaviour)

Done!

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

3 comments

  1. Posted by Chris 6th September, 2008 at 05:23 am |

    Excellent, thank you

  2. Posted by Abhi Beckert 13th September, 2008 at 07:07 pm |

    “Why didn’t I think of that?” Fantastic tip! thanks :)

  3. Posted by Abhi Beckert 16th September, 2008 at 02:13 am |

    I’m now using ([^\s]|\n) as the regex pattern, which functions as expected on empty lines and lines with only whitespace.

What do you think? Join the discussion...