如何在Sublime中选择变量的所有实例并编辑变量名称 [英] How to select all instances of a variable and edit variable name in Sublime
问题描述
如果我在代码中选择了一个变量(不仅是任何字符串),则该变量的所有其他实例都会在其周围出现笔触(白色轮廓):
If I select a variable (not just any string) in my code, all other instances of that variable get a stroke (white outline) around them:
是否有键盘快捷键可以让我选择所有这些变量实例并立即对其进行全部编辑?
Is there a keyboard shortcut that will let me select all of those instances of the variable and edit them all at once?
⌘ D ,⌘ K 和⌘ U 让我一个一个地选择它们,但是我必须手动排除不可变的字符串匹配项:
⌘D, ⌘K, and ⌘U lets me select them one-by-one, but I have to manually exclude the non-variable string matches:
并使用 Ctrl ⌘ G 只需选择 all 匹配的字符串:
And using Ctrl⌘G simply selects all the string matches:
很明显,Sublime能够区分变量匹配和字符串匹配.没有办法只选择变量匹配项吗?
Clearly, Sublime is able to differentiate between variable and string matches. Is there no way to select just the variable matches?
推荐答案
-
将光标置于变量中.
Put the cursor in the variable.
注意:关键是从一个空的选择开始.不要突出显示;只需将光标放在那里.
Note: the key is to start with an empty selection. Don't highlight; just put your cursor there.
- 根据需要按⌘ D .不在Mac上吗?使用 Ctrl D .
- Press ⌘D as needed. Not on a Mac? Use CtrlD.
没有工作吗?再试一次,确保从没有选择任何内容开始.
Didn't work? Try again, making sure to start with nothing selected.
更多命令:
查找全部: Ctrl ⌘ G 一次选择所有出现的事件.不在Mac上吗? Alt F3
Find All: Ctrl⌘G selects all occurences at once. Not on a Mac? AltF3
撤消选择: ⌘ U 向后退一步.不在Mac上吗? Ctrl U
Undo Selection: ⌘U steps backwards. Not on a Mac? CtrlU
快速跳过下一个: ⌘ K ⌘ D 跳过下一个事件.不在Mac上吗? Ctrl K Ctrl D
Quick Skip Next: ⌘K⌘D skips the next occurence. Not on a Mac? CtrlKCtrlD
这篇关于如何在Sublime中选择变量的所有实例并编辑变量名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!