Thank you, Allan, for the detailed instructions on assigning Indent Line to the tab key.
While we're on the topic of line indentation:
1. If you place the cursor at the end of a line and Shift Left, the cursor ends up at the start of the next line. This makes it very difficult to Shift Left more than once on the same line from the end of the line (which is a natural place to do it, after typing a semicolon).
2. When shifting left or right with the cursor at the start or middle of a line, the cursor position does not stay between the same characters after the shift; instead, its position stays constant relative to the start of the line. For example:
for i in array { object.method_call(| <--cursor ...oops I need to shift right... object.method_c|all(
The cursor should stay with the context it had before the shift. Keeping the absolute column position has the potential of shifting the cursor out of one scope into another. But more importantly, it's just plain disorienting to have the cursor move around relative to the text I was just typing. In the example above, I had paused before adding a method argument, and now if I continue to type the argument, I'm not in the right place anymore.
I noticed that when using the Indent Line command, the cursor position is correctly preserved relative to the text on the line. The same behavior should be used when shifting left and right.
Shawn
On Mon, 31 Oct 2005 03:49:36 +0100, Allan Odgaard wrote:
On 31/10/2005, at 3.11, Shawn Van Ittersum wrote:
How do we assign Tab key to the new Indent Line command ourselves, since you did not do that for us?
The action method (for the key bindings dictionary) is “indent:” (it's actually declared by NSResponder, though unimplemented by NSTextView).
A more flexible method is recording a macro:
- Automation / Start Macro Recording (option-cmd M)
- Text / Indent Line (option-cmd [)
- Automation / Stop Macro Recording (option-cmd M)
- Automation / Save Scratch Macro… (ctrl-cmd M)
Then give it TAB as key equivalent. Probably store it in an Emacs-compatibility bundle.
I am mentioning the macro as more flexible because this would allow you to:
a) limit the scope of the key, e.g. to source files, or source files except comments in sources (source - comment) etc., and b) because you can record further actions, you can get the indent to trigger on other keys as well, e.g. record inserting a “;” and then do the Text / Indent Line, bind that macro to the ; key (limited in scope to sources that terminate lines by a “;”) and you get the line properly indented when you type a “;” character.
p.s. Why are you making it so hard for emacs users to embrace your program??
Oh come on! I never used Emacs and I never planned for TextMate to be Emacs -- but I have made plenty of changes to TextMate only to suit Emacs users. But the role-model for behavior when it comes to TextMate is NSTextView and OS X, that should go without saying!