New command with new custom keyboard shortcut
Besides IntelliJ, I'm a frequent RStudio user. There's a very nice shortcut `Option-Minus` (the minus key, just to the left of the equal-sign key - but `Option--` didn't look very nice :-) that inserts a left-pointing arrow `<-` with appropriate whitespace around it (one space on each side, don't add spaces if they're already there). This arrow is the main assignment operator in R.
It's kind of funny how nice it is to use.
So I'd love to have that functionality in IntelliJ too, working like the following:
- When editing an R file, insert `<-` with appropriate whitespace around it
- When editing a Python file (or most other language files), insert `=` with appropriate whitespace around it.
and bind this in the "Keymap" preferences to `Option-Minus`.
I'm not exactly sure how to go about this - would this require writing a full-fledged plugin to handle the "appropriate whitespace" part?
Even if this were a simpler command to insert a static string instead of this dynamic insertion, is there an easy way to assign a shortcut like `Option-Minus` to it, or are Live Templates the only way to do custom string insertions? That would seem to rule out a quick keystroke shortcut like this, AFAIK Live Templates are only triggered by word-like shortcuts, right?
Suggestions welcome!
Please sign in to leave a comment.
Ethan Yin But this can't be done with Live Templates, for the reasons I outlined in my post, right?
Ken,
It could be done by using a macros, but currently there is an issue that it's not possible to set shortcut for macros: https://youtrack.jetbrains.com/issue/IDEA-314986
Also here is a request to add shortcuts for live templates: https://youtrack.jetbrains.com/issue/IDEA-67811