崇高文本多个光标快捷方式

Ada*_*air 5 shortcut sublimetext3

我是emacs的大用户,我绝对喜欢这样一个事实,即你可以在不使用鼠标的情况下做到一切.我的功能使emacs非常高效.

我也是Linux上Sublime Text的忠实粉丝.我喜欢你启用的多光标功能Ctrl+left_mouse_clik.我还发现你可以点击Shift+alt+arrow_up_or_down在上面或下面的行上创建一个新光标.所以我想知道在崇高文本中是否有一种方法可以在不使用鼠标的情况下在任何地方创建多个光标.

sku*_*oda 6

一种可能的解决方案是使用书签(如果您还没有).我不知道Linux键绑定在我的头顶,但你可以添加书签,然后选择所有.要查看适用于您的平台的绑定,请转到Goto -> Bookmarks,它们应该由命令列出.您还可以查看默认的键绑定文件.

第二种解决方案是使用插件.我刚才写了以下内容.我不记得,真的不能说它是否/如何运作.快速测试让我相信它运作正常.

import sublime
import sublime_plugin


class MultiCursorCommand(sublime_plugin.TextCommand):
    def run(self, edit, action="add"):
        self.key = "multi_cursor"
        cursors = self.view.sel()
        saved_cursors = self.view.get_regions(self.key)
        if action == "add":
            self.view.add_regions(self.key, list(cursors) + saved_cursors, "keyword", "", sublime.DRAW_EMPTY)
        elif action == "show":
            cursors.add_all(saved_cursors)
            self.view.add_regions(self.key, [])
        elif action == "show_begin":
            saved_cursors += list(cursors)
            cursors.clear()
            cursors.add_all([c.begin() for c in saved_cursors])
            self.view.add_regions(self.key, [])
        elif action == "show_end":
            saved_cursors += list(cursors)
            cursors.clear()
            cursors.add_all([c.end() for c in saved_cursors])
            self.view.add_regions(self.key, [])
        elif action == "show_visible":
            pass
        elif action == "clear":
            self.view.add_regions(self.key, [])
        elif action == "remove":
            for cursor in cursors:
                if cursor in saved_cursors:
                    saved_cursors.remove(cursor)
            self.view.add_regions(self.key, saved_cursors, "keyword", "", sublime.DRAW_EMPTY)


class RemoveCursorCommand(sublime_plugin.TextCommand):
    def is_enabled(self):
        return len(self.view.sel()) > 1

    def run(self, edit, forward=True):
        self.view.sel().subtract(self.view.sel()[0 if forward else -1])
Run Code Online (Sandbox Code Playgroud)

键绑定看起来像

{ "keys": ["alt+a"], "command": "multi_cursor", "args": {"action": "add"} },
{ "keys": ["alt+s"], "command": "multi_cursor", "args": {"action": "show"} }
Run Code Online (Sandbox Code Playgroud)

人们编写的插件控件中可能有同样的插件,我只是不知道它们.