windows 在 Sublime Text 2 中使用 Ctrl+D 进行多项选择时如何跳过匹配项?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11548308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I skip a match when using Ctrl+D for multiple selections in Sublime Text 2?
提问by Just_Mad
I have some code like:
我有一些代码,如:
testVar = { a: 1 };
testVariable1 = 2;
var c = testVar.a + testVariable2;
var d = testVar;
I want to rename "testVar" variable. When I set multiple cursors with Ctrl+Dand edit variable, "testVariable" is also selected and edited.
我想重命名“testVar”变量。当我用Ctrl+D和编辑变量设置多个光标时,也会选择和编辑“testVariable”。
Is there a way to skip some selections while setting multiple cursors with Ctrl+D?
有没有办法在使用Ctrl+设置多个光标时跳过一些选择D?
回答by Romain
Just use Ctrl+K, Ctrl+D.
只需使用Ctrl+ K, Ctrl+ D。
(for OS X: Cmd+K, Cmd+D)
(对于 OS X:Cmd+ K, Cmd+ D)
Needs a bit of practice, but gets the job done!
需要一些练习,但可以完成工作!
回答by SUB0DH
You can press Ctrl+Kand Ctrl+Dat the same time to skip a selection. If you went too far with your selection, you can use Ctrl+Uto return to a previous selection.
您可以同时按Ctrl+K和Ctrl+D跳过选择。如果您的选择太过分了,您可以使用Ctrl+U返回到之前的选择。
Note: Replace Ctrlwith Cmdfor Mac OS X.
注:更换Ctrl用Cmd的Mac OS X.
The default configuration for this can be viewed by going to Preferences
> Key Bindings-Default
in the application menubar, where you will see something like this:
可以通过转到应用程序菜单栏中的Preferences
>来查看此默认配置Key Bindings-Default
,您将在其中看到如下内容:
{ "keys": ["ctrl+d"], "command": "find_under_expand" },
{ "keys": ["ctrl+k", "ctrl+d"], "command": "find_under_expand_skip" }
If you want, you can configure the keys as per your needs, by going to Preferences
> Key Bindings-User
and copy the above code and then change the keys.
如果需要,您可以根据需要配置密钥,方法是转到Preferences
>Key Bindings-User
并复制上面的代码,然后更改密钥。
回答by Atomicflare
If you have the cursor over the word and use Ctrl+ Dto select the word. The next time you hit Ctrl+ Dit should select the next highlighted word.
如果您将光标悬停在单词上并使用Ctrl+D选择单词。下次你点击Ctrl+D它应该选择下一个突出显示的单词。
If you double click to select word, Ctrl+ Dwill select the exact string not just the highlighted ones.
如果双击选择单词,Ctrl+D将选择确切的字符串,而不仅仅是突出显示的字符串。
In other words, Ctrl+ Dwith nothing highlighted does whole-word search. If you have something highlighted already, Ctrl+ Dwill do substring searching.
换句话说,没有突出显示的Ctrl+D进行全字搜索。如果您已经突出显示了某些内容,Ctrl+D将进行子字符串搜索。
I have tested and it works in Sublime Text 2 Version 2.0.1, Build 2217.
我已经测试过,它适用于 Sublime Text 2 版本 2.0.1,构建 2217。
回答by n1nj4
Place curser beforethe variable, do not select the variable, hit Ctrl+Dto select every occurence of the variable, not pattern.
将光标放在变量之前,不要选择变量,点击Ctrl+D选择变量的每个出现,而不是模式。
回答by bevo009
Updated answer for vscode in 2020 on windows, in keybindings.json add this line to skip the next selected occurrence easily:
在 windows 上更新了 2020 年 vscode 的答案,在 keybindings.json 中添加这一行以轻松跳过下一个选定的事件:
{
"key": "ctrl+alt+d",
"command": "editor.action.moveSelectionToNextFindMatch",
"when": "editorFocus"
},
*yes I know the question is for sublime text, but I found it by googling the same question + vscode, so it might help someone since the mappings are identical.
*是的,我知道这个问题是针对崇高文本的,但我通过谷歌搜索相同的问题 + vscode 找到了它,因此它可能对某人有所帮助,因为映射是相同的。