Last active
December 22, 2015 22:39
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
// Reload currently active view key shortcut. | |
{ "keys": ["ctrl+alt+o"], "command": "reload_view"} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
// Reload currently active view key shortcut. | |
{ "keys": ["ctrl+super+o"], "command": "reload_view"} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
// Reload currently active view key shortcut. | |
{ "keys": ["ctrl+alt+o"], "command": "reload_view"} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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