如何选择sublime文本3中的下一个书签

dre*_*cko 4 sublimetext sublimetext3

有没有办法在SublimeText3中选择当前光标位置和下一个/上一个书签之间的文本?

shift键的组合不起作用:shiftF2转到上一个书签(即shift+ F2="转到下一个书签").shift选择"下一个书签"菜单项时按住也不起作用.

ser*_*oFC 8

为了做到这一点,你可能需要一个插件.我刚刚创建了这个简单的插件,它根据forward参数的值从当前光标位置选择下一个/上一个书签.

这是插件:

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)
Run Code Online (Sandbox Code Playgroud)

使用工具>新插件并使用提供的插件.将其另存为SelectToBookmark.py.最后,使用以下内容将keyBindings添加到用户文件:

{
    "keys": ["ctrl+alt+e"],
    "command": "select_to_bookmark",
    "args": {"forward": true}
}
Run Code Online (Sandbox Code Playgroud)

使用另一个keyBinding,并将forward参数设置为false,以从当前位置选择到上一个书签.

编辑:当用户@MattDMo评论:"确保将.py文件保存在Packages/User中 - 您可以通过选择Preferences - > Browse Packages找到系统上的目录(如果它没有自动出现). ..菜单选项"