Visual Studio IDE – 如何防止“查找和替换”跳转到下一个结果?

huangapple go评论90阅读模式
英文:

Visual Studio IDE - Find and Replace Prevent Jumping to Next Result?

问题

有没有办法或扩展程序可以防止 Visual Studio IDE 2022 在单击“Replace Next”按钮时滚动我的视图,这个按钮位于查找和替换相关窗口中?

我使用正则表达式代码进行查找和替换,所以每次按下“Replace Next”按钮时,我想验证文本是否被正确替换。但在我能够看到所做的更改之前,视图会滚动或切换到下一个匹配结果所在的文件。

我还喜欢运行 Visual Studio 的“Edit.FormatDocument”命令,以美化或清理替换文本时可能引起的不正确缩进,但在 Visual Studio 跳转到另一个文件的下一个匹配结果之前,我无法对当前文件执行此操作。

暂时关闭自动滚动到下一个结果的行为或在查找和替换窗口中添加另一个按钮,用于替换当前匹配的文本而不滚动到下一个文本,这将非常棒。

我尝试过制作自己的 Visual Studio 扩展来覆盖这种行为或制作自定义查找和替换命令,但很难找到类似这样的示例,而且我只是一个初学者。我甚至无法使用DTE.Find.FindReplace API做出一些工作。考虑到扩展需要与正则表达式兼容,我认为这将更加困难。

感谢您提供的任何意见或协助。

英文:

Is there any workaround or extension to prevent Visual Studio IDE 2022 from scrolling my view when clicking the "Replace Next" button in the Find-and-Replace related windows?

I use REGEX code with Find-and-Replace, and so I would like to verify that text is replaced correctly each time I press the "Replace Next" button. But the view scrolls or switches to another file with the next matching found result before I can see the changes that were made.

I also like to run Visual Studio's "Edit.FormatDocument" command to beautify or clean up the improper indenting made when replacing text, but I can't do that to my current file before Visual Studio jumps to the next matching result in another file.

It would be fantastic to temporarily turn off that auto-scroll-to-next-result behavior or to have another button in the Find-and-Replace windows that replaces the current matching text without scrolling to the next one.

I looked into making my own Visual Studio extension to override the behavior or to make a custom find and replace command but it's difficult to find examples for doing something like this and I'm just a beginner. I wasn't even able to get something working with the DTE.Find.FindReplace API. And with the addition of the extension needing to be compatible with REGEX I figure it will be more difficult.

Thank you for any input or assistance with this.

答案1

得分: 1

没有。对于“替换下一个”功能的焦点,Visual Studio没有配置来控制这个。也没有现成的扩展可以实现这个功能。我认为扩展也很难/无法实现这一点。我没有看到任何VS SDK提供这样配置的API。

如果你不想通过滚动视图来查看结果,可以考虑使用“查找所有”功能:

Visual Studio IDE – 如何防止“查找和替换”跳转到下一个结果?

如果你不想在单击“替换下一个”时移动焦点,可以考虑使用“全部替换”功能:

Visual Studio IDE – 如何防止“查找和替换”跳转到下一个结果?

英文:

> Is there any workaround or extension to prevent Visual Studio IDE 2022
> from scrolling my view when clicking the "Replace Next" button in the
> Find-and-Replace related windows?

The answer is NO.

For the focus of the "Replace Next" feature, Visual Studio doesn't have such configuration to control this. And also doesn't have such an already-made extension.

And I think extenion also hard/unable to achieve this. I didn't see any API of VS SDK give such configuration.

If you don't want to see the results via scrolling the view. what about "find all" feature:

Visual Studio IDE – 如何防止“查找和替换”跳转到下一个结果?

If you don't want focus move when click "replace next", what about "replace all" feature:

Visual Studio IDE – 如何防止“查找和替换”跳转到下一个结果?

huangapple
  • 本文由 发表于 2023年7月13日 19:05:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678667.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定