Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Show a input panel to switch to a currently open file
import sublime_plugin
import os
# -------------------------------------------
# You will need to create a key mapping for this, something like:
# { "keys": ["alt+e"], "command": "switch_to_file" }
# -------------------------------------------
class SwitchToFileCommand(sublime_plugin.WindowCommand):
def run(self):
self.display_list = []
self.views = []
for view in self.window.views():
path = view.file_name()
if view.is_scratch():
name =
path = '(view id = %d)' % (
elif not path:
name = 'Untitled'
path = '(view id = %d)' % (
name = os.path.split(path)[1]
self.display_list.append([name, path])
self.window.show_quick_panel(self.display_list, self.switch_to_view, False)
def switch_to_view(self, index):
if index >= 0 and len(self.views) > index:

Sorry, but where I must place this python file for this work?

import sublime_plugin ;)

Also import os

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment