regexvisual-studio-code

VS Code regular expression white space including newlines?


Attempting to match white space including newlines followed by a brace, { or } then collapse the matching white space to a single space, .

Matches \s*([{}]) do not include the preceding newlines:

VS Code match

So, the replacement $1 does not collapse the newlines:

VS Code replacement


Solution

  • You can use: (UPDATE)

    \s*([{}])
    

    Produces:

    VS Code collapses white space including newlines to a single space