Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
philc opened this issue Apr 4, 2011 · 9 comments

Comments

@philc
Copy link
Owner

philc commented Apr 4, 2011

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
Copy link

jrk commented Apr 6, 2011

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?

@philc
Copy link
Owner Author

philc commented Apr 6, 2011

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
Copy link
Owner Author

philc commented Apr 6, 2011

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
Copy link

jrk commented Apr 6, 2011

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:
#4 (comment)

@jrk
Copy link

jrk commented Apr 6, 2011

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)

@philc
Copy link
Owner Author

philc commented Apr 6, 2011

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 philc closed this as completed Apr 6, 2011
@philc
Copy link
Owner Author

philc commented Apr 6, 2011

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:
#4 (comment)

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

@jrk
Copy link

jrk commented Apr 6, 2011

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)

@philc philc reopened this Apr 11, 2011
@philc
Copy link
Owner Author

philc commented Apr 11, 2011

Oops, didn't mean to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants