开发者

TextMate: Shortcut to go to the first non-whitespace character in the line

I really like TextMate. However, after using it for a long time and searching several times, I haven't been able to find a shortcut that takes me to the beginning of the line the way I want. I commonly want the cursor at the beginning of the line, but after the whitespace.

For example, in the following code if the cursor is at the end of the line with puts 'hi', and then I type ⌘ ←, it will put the cursor at the very beginning of the line, and I would rather that it put the cursor next to the 'p' at the beginning of the line. Is there such a shortcut?

class Test
  def greet
    puts 'hi'
  end
end
开发者_JAVA技巧


Although it's not a one-keypress solution, when I want to do that I press...

  1. CMD + ←
  2. OPT + →


I don't have textmate installed at the moment but I believe you can record a macro that jumps to the beginning of the line then searches forward for (?<=\s*)(?=[^\s]+).


It has been nicely explained here:

  • 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)

I bound home to this macro.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜