简体   繁体   English

崇高文字3跳过突出显示的单词

[英]Sublime Text 3 Jump through the highlighted word

With Visual Studio I can use the command Edit.NextHighlightedReference and Edit.PreviousHighlightedReference which are mapped to Ctrl + Shift + and Ctrl + Shift + . 在Visual Studio中,我可以使用命令Edit.NextHighlightedReferenceEdit.PreviousHighlightedReference映射到Ctrl + Shift + Ctrl + Shift + Using this command I can jump through the current highlighted word. 使用此命令,我可以跳过当前突出显示的单词。

Does Sublime Text 3 have a similar command or keyboard shortcut that I can use? Sublime Text 3是否具有我可以使用的类似命令或键盘快捷键?

I don't use Visual Studio, but according to this MSDN blog entry and it's description of this feature, it's possible to do something similar in Sublime. 我不使用Visual Studio,但是根据此MSDN博客条目及其对此功能的描述,可以在Sublime中执行类似的操作。

The blog entry describes the feature as automatically highlighting all of the references to the symbol under the caret and allowing you to jump between those references in the current file with key bindings. 博客条目将功能描述为自动突出显示插入符号下该符号的所有引用,并允许您使用键绑定在当前文件的这些引用之间跳转。

In Sublime it's possible to navigate between references to a symbol as well as to the definition of a symbol, but this is done based on the syntax in use and doesn't have the granularity that is required here. 在Sublime中,可以在对符号的引用以及符号的定义之间进行导航,但这是根据使用的语法完成的,没有此处要求的粒度。

You can see this in action by hovering your mouse over a symbol. 您可以通过将鼠标悬停在符号上来查看此操作。 If you have show_definitions and index_files turned on in your settings (they're both turned on by default) and the text under the cursor is a symbol, you'll be shown a popup that allows you to navigate to the definition and/or references. 如果您在设置中打开了show_definitionsindex_files (默认情况下都将它们都打开)并且光标下方的文本是符号,则会显示一个弹出窗口,允许您导航到定义和/或引用。

Note that there is no "deep analysis" done on the symbol, so for example two open files with similar method names may be intermixed in the list, if the symbol isn't something like a method or function it may not be included, etc. 请注意,对符号没有进行“深度分析”,因此,例如,两个具有相似方法名称的打开文件可能会混合在列表中,如果符号与方法或函数不符,则可能不包括在内,等等。 。

Additionally, although you can bind keys to these actions, if there is more than one reference you will be prompted with a quick panel instead of cycling between them. 此外,尽管您可以将按键绑定到这些操作,但是如果引用不止一个,则会通过快速面板提示您,而不是在它们之间循环。

Third party packages can enhance this by doing their own analysis of the code. 第三方程序包可以通过自己分析代码来增强此功能。 Possibly the SublimeCodeIntel package does this, although I don't use it myself so I can't say for sure. SublimeCodeIntel软件包可能会执行此操作,尽管我自己不使用它,所以不能确定。

You can sort of replicate what you want in core Sublime by utilizing the search functionality in the current buffer, which may be enough depending on your exact needs. 您可以利用当前缓冲区中的搜索功能,在核心Sublime中复制所需的内容,根据您的确切需求,这可能就足够了。 A downside of this is that it doesn't constrain the results to just the symbol, but any matching text (comments, similarly named variables, etc). 不利的一面是,它不仅将结果限制在符号上,而且还限制了任何匹配的文本(注释,类似命名的变量等)。

The workflow works something like this (key bindings here are for Windows/Linux): 工作流的工作原理如下(键绑定适用于Windows / Linux):

  1. Place the cursor in the symbol and press Ctrl+D ; 将光标置于符号中,然后按Ctrl + D Sublime will select the word under the cursor and highlight the other occurrences in the buffer; Sublime将选择光标下方的单词,并突出显示缓冲区中的其他单词; You can also instead press Ctrl+F3 which will do this and then immediately jump to the next match. 您也可以按Ctrl + F3组合键,然后立即跳至下一个匹配项。
  2. Press F3 to search forwards through the other occurrences in the current buffer, eventually wrapping around back to where you started. F3键向前搜索当前缓冲区中的其他事件,最后回绕到开始的位置。
  3. Press Shift+F3 to search backwards instead of forwards Shift + F3可以向后搜索,而不是向前搜索

Note that this only works when you use Ctrl+F3 or Ctrl+D to select; 请注意,这仅在使用Ctrl + F3Ctrl + D进行选择时才有效。 regular selections have no effect on this. 常规选择对此没有影响。 If you do that, pressing the search keys will continue the search you used last (which can be a good thing or a bad thing depending on what you intended to do). 如果这样做,按搜索键将继续您上次使用的搜索(根据您的意图,这可能是好事,也可能是坏事)。

Adding the following to your custom key bindings would allow you to use the key bindings you're used to for navigating between the matches (although they override default keys for swap_line_up and swap_line_down ): 将以下内容添加到自定义键绑定中将使您能够使用习惯于在匹配项之间导航的键绑定(尽管它们会覆盖swap_line_upswap_line_down默认键):

{
    "keys": ["ctrl+shift+up"], "command": "find_prev"
},
{
    "keys": ["ctrl+shift+down"], "command": "find_next"
},

If you're interested, the command find_under is what is mapped to Ctrl+F3 and find_under_expand is bound to Ctrl+D , should you want to bind those to something else as well. 如果您感兴趣,可以将命令find_under映射到Ctrl + F3并将find_under_expand绑定到Ctrl + D ,如果您也想将其绑定到其他对象。

For completeness, the associated key bindings for MacOS are ⌘+Alt+G and ⌘+D for the two commands that start the search and ⌘+G and ⌘+Shift+G for going forwards and backwards through the matches. 为了完整起见,MacOS的关联键绑定是用于启动搜索的两个命令的⌘+ Alt + G⌘+ D ,以及用于在匹配中前后移动的 ⌘+ G⌘+ Shift + G。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM