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!
Excellent, thank you
“Why didn’t I think of that?” Fantastic tip! thanks
I’m now using ([^\s]|\n) as the regex pattern, which functions as expected on empty lines and lines with only whitespace.