Multiline regular expression search in Visual Studio Code

Solution 1:

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: October 2018 release notes


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.

multiline find widget.

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.

Solution 2:

yes, you could use regex for mutliple line search in VScode.

To find a multi-line text block starting from aaa and ending with the first bbb (lazy qualifier)

aaa(.|\n)+?bbb

To find a multi-line text block starting from aaa and ending with the last bbb. (greedy qualifier)

aaa(.|\n)+bbb