import sublime, sublime_plugin
class SelectToBookmarkCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
"""Get initial position"""
initialPoint = self.view.sel()[0].begin()
"""Clear selected things (if any)"""
self.view.sel().clear()
"""Move to next bookmark or previous bookmark"""
forward = args.get('forward','true')
if forward is True:
self.view.run_command("next_bookmark")
else:
self.view.run_command("prev_bookmark")
"""Get current position (position of the bookmark)"""
finalPoint = self.view.sel()[0].begin()
"""Clear selected things (if any)"""
self.view.sel().clear()
"""Region to select"""
regionToSelect = sublime.Region(initialPoint, finalPoint)
"""Add the region to the selection"""
self.view.sel().add(regionToSelect)
import sublime, sublime_plugin
class SelectToBookmarkCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
"""Get initial position"""
initialPoint = self.view.sel()[0].begin()
"""Clear selected things (if any)"""
self.view.sel().clear()
"""Move to next bookmark or previous bookmark"""
forward = args.get('forward','true')
if forward is True:
self.view.window().run_command("sublime_bookmark",{ "type" : "goto_previous" })
else:
self.view.window().run_command("sublime_bookmark",{ "type" : "goto_next" })
"""Get current position (position of the bookmark)"""
finalPoint = self.view.sel()[0].begin()
"""Clear selected things (if any)"""
self.view.sel().clear()
"""Region to select"""
regionToSelect = sublime.Region(initialPoint, finalPoint)
"""Add the region to the selection"""
self.view.sel().add(regionToSelect)
2 回答
为了做到这一点,你可能需要一个插件 . 我刚刚创建了这个简单的插件,它根据forward参数的值从当前光标位置选择下一个/上一个书签 .
这是插件:
使用工具>新插件并使用提供的插件 . 将其另存为SelectToBookmark.py . 最后,使用以下内容将keyBindings添加到用户文件中:
使用另一个keyBinding,并将forward参数设置为false,以从当前位置选择到上一个书签 .
编辑:正如用户@MattDMo评论:“确保将.py文件保存在Packages / _751173中 - 您可以通过选择首选项 - >浏览包来找到系统上的目录(如果它没有自动出现) . ..菜单选项“
类似于@ sergioFC的回答 . 此版本用于SublimeBookmark包 .