Sublime Forum

Defining a shortcut which inserts some characters for a particular file type?

#1

There is a syntax specific settings file which allows me to set various options for a particular file type.

I would like to add an option to this file which is something like a macro: if I press a certain combination of keys, or perhaps select the appropriate command from the command palette, it will paste a certain sequence of characters and place the the cursor after a particular character in the pasted sequence.

For example, maybe I would like to set ALT+F to insert the character sequence \f{} at the current position of my cursor, and once this sequence is inserted, my cursor would be placed in between the parentheses.

I think that for my actual use case (LaTeX), I should set up an auto-completion file completes certain commands for me, rather than doing the above. However, out of curiosity, I am wondering if it is possible to do something like what I have described.

0 Likes

#2

I don’t think there are syntax specific keybindings, but you could use snippets instead.

1 Like

#3

There are syntax specific key bindings by using a context and the selector key.

https://www.sublimetext.com/docs/3/key_bindings.html#context

2 Likes