Visual Studio Code 中的多行正则表达式搜索 [英] Multiline regular expression search in Visual Studio Code

查看:69
本文介绍了Visual Studio Code 中的多行正则表达式搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多行正则表达式搜索在 VS Code 1.27.2 版中不起作用.

理论上 aaa(\n|.)*bbb 应该找到从 aaa 开始到 bbb 结束的字符串,但它不起作用.此处提到的解决方案

<小时>

多行搜索将在 v1.38 中加入 Find Widget.请参阅 .

奇怪在查找小部件中是 Ctrl+EnterShift+在搜索面板中输入(请参阅下面的 Deepu 的回答).Shift+Enter 在 Find Widget 获得焦点时具有其他功能.

Multiline regular expression search doesn't work in VS Code version 1.27.2 .

Theoretically aaa(\n|.)*bbb should find string starting from aaa and ending bbb but it doesn't work. The solution mentioned here Multi-line regular expressions in Visual Studio Code doesn't work as well.

解决方案

Multiline search is added in v1.29 released in November 2018. See multi-line search.

VS Code now supports multiline search! Same as in the editor, a regex search executes in multiline mode only if it contains a \n literal. The Search view shows a hint next to each multiline match, with the number of additional match lines.

This feature is possible thanks to the work done in the ripgrep tool to implement multiline search.


Multiline search is coming to the Find Widget with v1.38. See multiline find "pre-release" notes.

Multi Line search in Find Widget

The Find Widget now supports multiple line text search and replace. By pressing Ctrl+Enter, you can insert new lines into the input box.

.

Odd that it is Ctrl+Enter in the Find Widget but Shift+Enter in the Search Panel (see Deepu's answer below). Shift+Enter has other functionality when the Find Widget is focused.

这篇关于Visual Studio Code 中的多行正则表达式搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆