在Sublime Text 2中,是否可以立即选择所有其他(或奇数/偶数)行并在这些行上放置多个游标?
感谢。
答案 0 :(得分:343)
.*\n.*\n
答案 1 :(得分:98)
您可以轻松完成:
编辑:
(.*(\n|$)){2}
表达式答案 2 :(得分:11)
我正在寻找一种在崇高中选择替代线的方法。
感谢Joe Daley给出了一个非常好的答案。 虽然我意识到,如果使用正则表达式,如果文件末尾没有换行符,则不会选择文件中的最后一行。
我想改善这个答案,但我现在似乎没有足够的声誉对上述答案发表评论。
您可以在打开正则表达式的情况下使用以下搜索字符串,然后按alt + enter。接着是左箭头。这会将光标分别放在备用线上(与Joe Daley解释的步骤相同)
^.*\n.*$
答案 3 :(得分:7)
您可以尝试使用插件:Tools/New Plugin...
import sublime_plugin
class ExpandSelectionToOtherLinesCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().run_command("expand_selection", {"to": "line"})
start_region = self.view.sel()[0]
self.view.window().run_command("select_all")
self.view.sel().subtract(start_region)
将此文件保存在Packages/User
。
然后,添加该插件的键绑定:
{ "keys": ["super+alt+l"], "command": "expand_selection_to_other_lines" }
此命令将选择所有其他行。当您选择其他行时,可以使用Split selection into lines
命令( Ctrl + Shift + L , Cmd + Shift + L 。
如果你想在一个快捷方式中拥有everythnig,你可以像这样修改插件:
import sublime_plugin
class ExpandSelectionToOtherLinesCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.window().run_command("expand_selection", {"to": "line"})
start_region = self.view.sel()[0]
self.view.window().run_command("select_all")
self.view.sel().subtract(start_region)
self.view.window().run_command("split_selection_into_lines")
self.view.window().run_command("move", {"by": "characters", "forward": False})
最后一行只是删除选择,在选定行的开头留下多个游标。