philc/textmatevim

O (open line) should place the cursor at the appropriate indentation level

Opened this issue · 9 comments

This is to match Vim's behavior, and because it's generally useful.

O with a numeric modifier (e.g. adding 10 lines) probably shouldn't indent.

jrk commented

I was thinking of attacking this myself and wondered: how are you doing introspection to discover the range of editing methods (e.g. the many methods called as strings in editor_commands.rb) in TextMate?

Hey JRK, feel free to tackle it. In the developers file it mentions that most of textmate's text-editing methods come from the NSResponder class in Cocoa.

There's unlikely a command in NSResponder which will do the trick. Assuming not, you might need to try something like sending along the tab key when a new line is opened and letting textmate do its indentation logic.

Actually upon closer inspection, the current implementation of insert_newline_below should work in theory. Maybe we need to replace "addNewLine" with a simulated enter key so TextMate steps in and implements indentation.

jrk commented

Thanks. Saw the developers file shortly after posting. Nice reference for TextMate hacking in general. I also remembered that TextMate reports most of these NSResponder methods and arguments directly for macros in the bundle editor, making macro recording a useful way to quickly experiment. Your Vim-style setup seems like an ideal model just for managing a larger library of personal macros without having to fumble with the bundle editor and custom plist files, instead just using a Ruby DSL in a dotfile.

Great work so far.

On Apr 6, 2011, at 3:12 PM, philc reply@reply.github.com wrote:

Hey JRK, feel free to tackle it. In the developers file it mentions that most of textmate's text-editing methods come from the NSResponder class in Cocoa.

There's unlikely a command in NSResponder which will do the trick. Assuming not, you might need to try something like sending along the tab key when a new line is opened and letting textmate do its indentation logic.

Reply to this email directly or view it on GitHub:
#4 (comment)

jrk commented

I believe the method desired in this particular case is insertNewline.

On Apr 6, 2011, at 3:15 PM, philc wrote:

Actually upon closer inspection, the current implementation of insert_newline_below should work in theory. Maybe we need to replace "addNewLine" with a simulated enter key so TextMate steps in and implements indentation.

Reply to this email directly or view it on GitHub:
#4 (comment)

Ah; we have a custom implementation of insert newline in TextMateVimWindow.m, as I didn't know such a command existed:

  • (void)addNewline { [self.oakTextView insertText:@"\n"]; }

Maybe using insertNewline instead will do the trick and properly trigger Textmate's indentation.

Ah; we have a custom implementation of insert newline in
TextMateVimWindow.m, as I didn't know such a command existed:

  • (void)addNewline { [self.oakTextView insertText:@"\n"]; }

Maybe using insertNewline instead will do the trick and properly trigger
Textmate's indentation.

On Wed, Apr 6, 2011 at 1:40 PM, jrk <
reply@reply.github.com>wrote:

I believe the method desired in this particular case is insertNewline.

On Apr 6, 2011, at 3:15 PM, philc wrote:

Actually upon closer inspection, the current implementation of
insert_newline_below should work in theory. Maybe we need to replace
"addNewLine" with a simulated enter key so TextMate steps in and implements
indentation.

Reply to this email directly or view it on GitHub:
#4 (comment)

Reply to this email directly or view it on GitHub:
#4 (comment)

jrk commented

It certainly seems to within the macro system, which suggests it would in general.

On Apr 6, 2011, at 4:43 PM, philc wrote:

Ah; we have a custom implementation of insert newline in TextMateVimWindow.m, as I didn't know such a command existed:

  • (void)addNewline { [self.oakTextView insertText:@"\n"]; }

Maybe using insertNewline instead will do the trick and properly trigger Textmate's indentation.

Reply to this email directly or view it on GitHub:
#4 (comment)

Oops, didn't mean to close this issue.