4

How do I open a specific file with a custom command palette entry or with a key binding aka shortcut key?

There are some files I open a lot but are not associated with any specific project. It would be useful to be able to open them quickly using the command palette or with a key binding.

1 Answer 1

9

It took a few minutes of trial and error to work out how but here's how to do it.

To add an entry in the command palette to open a specific file, add a modified version of the following template to your user Default.sublime-commands file.

// Modify the caption "File Open: Whatever" to something // appropriate and of course change the file path. { "caption": "File Open: Whatever", "command": "open_file", "args": {"file": "/path/to/whatever"} }, 

To add a key binding to open a specific file, add a modified version of the following template to your user Default (OS).sublime-keymap file.

// Modify the key bindings to what you want and change the file path. { "keys": ["ctrl+t", "ctrl+w"], "command": "open_file", "args": {"file": "/path/to/whatever"} }, 

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.