textmatevim icon indicating copy to clipboard operation
textmatevim copied to clipboard

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

Open philc opened this issue 14 years ago • 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.

philc avatar Apr 04 '11 18:04 philc

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?

jrk avatar Apr 06 '11 01:04 jrk

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.

philc avatar Apr 06 '11 19:04 philc

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.

philc avatar Apr 06 '11 19:04 philc

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 [email protected] 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: https://github.com/philc/textmatevim/issues/4#comment_965560

jrk avatar Apr 06 '11 20:04 jrk

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: https://github.com/philc/textmatevim/issues/4#comment_965575

jrk avatar Apr 06 '11 20:04 jrk

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.

philc avatar Apr 06 '11 20:04 philc

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 < [email protected]>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: https://github.com/philc/textmatevim/issues/4#comment_965575

Reply to this email directly or view it on GitHub: https://github.com/philc/textmatevim/issues/4#comment_965966

philc avatar Apr 06 '11 20:04 philc

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: https://github.com/philc/textmatevim/issues/4#comment_965989

jrk avatar Apr 06 '11 21:04 jrk

Oops, didn't mean to close this issue.

philc avatar Apr 11 '11 07:04 philc