Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text open a specific file with the command palette or key binding

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.

like image 552
mattst Avatar asked Sep 15 '25 08:09

mattst


1 Answers

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.

like image 99
mattst Avatar answered Sep 18 '25 09:09

mattst