How do I open a file using only keyboard in Sublime Text 2/3?
Looking for equivalent of
<Esc>:e /path/to/file from Vim.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
On OS X, Press Cmd-O to open the file browser.
Then, Cmd-Shift-G allows you to enter the name of the folder to go to.
Finally, just type the file name (or a unique prefix) to select the file you want. You can also navigate using the arrow keys.
The following plugin allows you to type a file name and have it opened in Sublime Text 2. It should work on any OS.
import sublime, sublime_plugin def open_file(window, filename): window.open_file(filename, sublime.ENCODED_POSITION) class OpenFileByNameCommand(sublime_plugin.WindowCommand): def run(self): fname = self.window.active_view().file_name() if fname == None: fname = "" def done(filename): open_file(self.window, filename) self.window.show_input_panel( "file to open: ", fname, done, None, None)
This allows you to encode a position in that file in the file name:
/path/to/file:42will open the file and go to line 42
/path/to/file:42:23will open the file and go to line 42, column 23
For information how plugins work and how you can integrate this in the UI, see this answer.
Why don't you just use the Ctrl-P? (
Goto -> Goto anything)
I recently wrote a plugin, iOpener, that will open files from path using completion, directory listings and history. It also sensibly opens folders by adding the into the side bar of a new window.
I tried to emulate the functionality of emacs were possible.
(I know this question is for ST2. I could always back-port the code if there were enough demand. Though I suspect most people use ST3 now.)
Verified on ST3.1.1, Build 3176. This should work without any plugin.
To open a file which is not part of the project, for example ~/.bashrc:
On Ubuntu, you can use Ctrl-O to get to the file open dialog, and then Ctrl-L to get a line for writing the file name. This also works for hidden files.
On MacOS, use Cmd-O and Cmd-Shift-G.
For project files, use Ctrl-P respective Cmd-P.