我是emacs的狂热用户,我绝对喜欢你可以在不使用鼠标的情况下完成所有操作。我认为这个功能使得emacs非常高效。
我也是Linux上Sublime Text的忠实粉丝。我喜欢通过Ctrl+left_mouse_clik
启用的多光标特性。我还发现,您可以单击Shift+alt+arrow_up_or_down
来创建上方或下方行的新光标。因此,我想知道是否有一种方法可以在Sublime Text中在任何位置创建多个光标而不使用鼠标。
我是emacs的狂热用户,我绝对喜欢你可以在不使用鼠标的情况下完成所有操作。我认为这个功能使得emacs非常高效。
我也是Linux上Sublime Text的忠实粉丝。我喜欢通过Ctrl+left_mouse_clik
启用的多光标特性。我还发现,您可以单击Shift+alt+arrow_up_or_down
来创建上方或下方行的新光标。因此,我想知道是否有一种方法可以在Sublime Text中在任何位置创建多个光标而不使用鼠标。
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])
按键绑定通常是这样的格式
{ "keys": ["alt+a"], "command": "multi_cursor", "args": {"action": "add"} },
{ "keys": ["alt+s"], "command": "multi_cursor", "args": {"action": "show"} }
可能已经有人编写了相同功能的插件,并放到了软件包控制上,只是我不知道它们。