1

Is there a way to print something with the given keybinding in Sublime Text 4?

E. g. for the sake of R, I would like the alt+oem_minus and alt+- keybindings strokes to result in <-.

I understand that for whatever I want to do, I can record a macro and this would work just fine but this action is so trivial that I wonder whether I can do without macro.

I understand that there are probably language plugins and IDEs that include this feature by default, but the most apparent one, the R-IDE, doesn't seem to have it, and moreover, Sublime is just an editor for quick scripts, not a comprehensive IDE, I have to intention to aggravate the app with scripts I do not need.

Thank you in advance for any response!

Lamha Llaw
  • 65
  • 4
  • 1
    Does this answer your question? [Sublime Text: how to make shortcut for inserting text?](https://stackoverflow.com/questions/15582210/sublime-text-how-to-make-shortcut-for-inserting-text) – Zakk Sep 11 '21 at 10:14
  • Yes, it does. I apologise for insufficient googling, that answer didn't emerge among search results or similar questions. Shall I, therefore, delete my question, or may it remain? – Lamha Llaw Sep 12 '21 at 13:53

1 Answers1

2

Open Sublime Text, go to Preferences > Key Bindings and add this:

[
    {
        "keys": ["alt+keypad_minus", "alt+-"],
        "command": "insert_snippet",
        "args": {"contents": "<-"}
    }
]

If you want to position the cursor after <-, you can do it via $0 like this:

"args": {"contents": "<- $0"}
Zakk
  • 1,935
  • 1
  • 6
  • 17