Jump to EOL and insert

Hi there — I’m trying to recreate a set of shortcuts I use constantly in TextMate:

  1. Go to the end of the current line and insert a newline character (cmd + return)
  2. Go to the end of the current line and insert a specific character (e.g. in JavaScript and CSS files it would be a semicolon) (option + cmd + return)
  3. Same as #2 but also insert a newline character (shift + cmd + return)

Any pointers as to where in the API I should look for how to do this?

1 Like

Hi @greystate.

I would take a look at CommandRegistry ( https://docs.nova.app/api-reference/commands-registry/) to register a command that can be then bound to the command palette and menu items. From there, you will probably need a combination of the Range, Scanner, Text Document, TextEdit, and/or TextEditor sections of the API.

Here you will find some information about defining a command, including shortcuts and any filters you wish to apply to the command (https://docs.nova.app/extensions/commands/#defining-a-command).

Ah - thanks Jason. Looks like the right place to start.

No worries Chriztian. Good luck!

Hey Chriztian,

I wrote an extension that does some of the stuff you’re looking for. It uses hotkeys to insert a line before or after the current line, without the additional character insertion you want.

Please feel free to use it as the basis for what you’re doing. I’m open to contributions if you think there’s a way to add your features to my extension in a non-breaking way.

https://extensions.panic.com/extensions/org.jbree/org.jbree.InsertLine/

Hi Joshua,

That’s awesome - I’ll take a peek and see what I can come up with.

Thanks a lot!