-
-
Save yongkangchen/10224897 to your computer and use it in GitHub Desktop.
Revisions
-
yongkangchen revised this gist
Apr 9, 2014 . 2 changed files with 2 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,3 @@ Open keyboard bindings file, and add a line to it ```js This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def run(self, edit): m = filename_re.search(whole_line, col) if m: filename = m.group() sublime.status_message("Opening file '%s'" % (filename)) self.view.window().open_file(filename) else: sublime.status_message("No filename discovered") -
yongkangchen revised this gist
Apr 9, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ VALID_FILENAME_CHARS = "-_.() %s%s%s" % (string.ascii_letters, string.digits, "/\\") filename_re = re.compile(r'[\w/\.-]+') class OpenFileAtCursor(sublime_plugin.TextCommand): def run(self, edit): for region in self.view.sel(): # Find anything looking like file in whole line at cursor -
Suor revised this gist
Nov 7, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ Open keyboard bindings file, and add a line to it ```js [ ... { "keys": ["alt+o"], "command": "open_file_at_cursor" } // this one ] ``` -
Suor revised this gist
Nov 7, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ ```bash cd ~/.config/sublime-text-2/Packages/User/ curl -O https://raw.github.com/gist/1344471/open_file_at_cursor.py ``` Open keyboard bindings file, and add a line to it ```js [ ... { "keys": ["alt+o"], "command": "open_filename_under_cursor" } // this one ] ``` -
Suor revised this gist
Nov 7, 2011 . 1 changed file with 12 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,13 @@ ```bash cd ~/.config/sublime-text-2/Packages/User/ curl -O https://gist.github.com/raw/1344471/0960b96154988c78245fca365228499e212a80cb/open_file_at_cursor.py ``` Open keyboard bindings file, and add a line to it ```js [ ... { "keys": ["alt+o"], "command": "open_filename_under_cursor" } ] ``` -
Suor created this gist
Nov 7, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ ``` cd ~/.config/sublime-text-2/Packages/User/ curl -O This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import sublime, sublime_plugin import os.path, string import re VALID_FILENAME_CHARS = "-_.() %s%s%s" % (string.ascii_letters, string.digits, "/\\") filename_re = re.compile(r'[\w/\.-]+') class OpenFilenameUnderCursor(sublime_plugin.TextCommand): def run(self, edit): for region in self.view.sel(): # Find anything looking like file in whole line at cursor whole_line = self.view.substr(self.view.line(region)) row, col = self.view.rowcol(region.begin()) while col >= len(whole_line) or whole_line[col] in VALID_FILENAME_CHARS: col -= 1 m = filename_re.search(whole_line, col) if m: filename = m.group() print "Opening file '%s'" % (filename) self.view.window().open_file(filename) else: print "No filename discovered"