ExpandRegion for Sublime Text:快速选择文本

有没有特别羡慕WebStorm上的CTRL+W快捷键,通过它可以迅速的选择光标下的文本,多按几次可以逐渐扩大选择的区域,这在编辑文本的时候简直太方便了。Vim也有类似的概念,在Vim中叫文本对象(text object),可以快速选择不同大小的文本对象。

在Sublime Text中虽然也有选择文本的快捷键,但是不够好用,直到有一天遇到这个插件:sublime-expand-region,一切的烦恼都消失了。

Like "Expand Selection to Scope". But better!

ExpandRegion works a bit like the build in "Expand Selection to Scope", however it does not depend on Scopes (Scopes are used by ST to "understand" code, i.e. for syntax highlighting). Therefore selection expansion can be more granular and customizable.

It works similar to ExpandRegion for Emacs and "Structural Selection" (Control-W) in the JetBrains IDE's (i.e. IntelliJ IDEA).

安装方法就不说了,一是上面的链接说到怎么安装了,另外用SublimeText的人大概也都知道怎么安装插件。所以这里就不罗嗦了。

这里只说一下我配置的快捷键。光安装还不能使用,得自定义两个快捷键,一个用于扩大选区,一个用于减小选区。

    {
        "keys": ["alt+up"],
        "command": "expand_region"
    },
    {
        "keys": ["alt+down"],
        "command": "expand_region",
        "args": {"undo": true},
        "context": [{ "key": "expand_region_soft_undo" }]
    },

以上快捷键定义适用于Windows、Linux、macOS

下面是几个效果图:

JavaScript (should also work for other c'ish languages like Java).

Python

HTML

原文地址:https://www.cnblogs.com/ingvar/p/5721106.html