Skip to content

Instantly share code, notes, and snippets.

@sligodave
Last active December 22, 2015 22:39
Show Gist options
  • Save sligodave/6541279 to your computer and use it in GitHub Desktop.
Save sligodave/6541279 to your computer and use it in GitHub Desktop.
A sublime text command to reload the current file and bring cursor back to current position.
[
// Reload currently active view key shortcut.
{ "keys": ["ctrl+alt+o"], "command": "reload_view"}
]
[
// Reload currently active view key shortcut.
{ "keys": ["ctrl+super+o"], "command": "reload_view"}
]
[
// Reload currently active view key shortcut.
{ "keys": ["ctrl+alt+o"], "command": "reload_view"}
]
class ReloadViewCommand(sublime_plugin.WindowCommand):
def run(self):
view = self.window.active_view()
if view:
file_name = view.file_name()
if file_name:
sel = view.sel()
if sel:
location = ''.join([':%d' % (x + 1) for x in view.rowcol(sel[0].begin())])
file_name += location
self.window.run_command('close')
self.window.open_file(file_name, sublime.ENCODED_POSITION)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment