sublime-surround
sublime-surround copied to clipboard
Be smarter about comments
If the selection does not start or end in a comment, matches in comments should be ignored. Otherwise look inside comments.
Sample code:
import sublime
import sublime_plugin
# This is a comment.
# Place the cursor in here and enter in the console:
# >>> view.run_command('test_comment')
# => source.python comment.line.number-sign.python
# Should be safe to check for /comment/ ?
class TestCommentCommand(sublime_plugin.TextCommand):
""" This is a string not a comment
"""
def run(self, edit):
sel = self.view.sel()[0]
scope = self.view.scope_name(sel.begin())
sublime.message_dialog(scope)