vs-code: Append a text to multiple opened files using regex?

I'm trying to append some text to multiple files. Is this possible in VS-Code with Edit->"Replace in Files" using regex?

enter image description here

\z (only the end of text) is not working here - invalid regular expression.

Upvotes: 1

Views: 2217

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626920

You may match the end of line that has no character immediately to the right:

$(?![\w\W])

Here, $ matches an end of line position and (?![\w\W]) is a negative lookahead that fails the match if any char appears immediately to the right of that location.

See the regex demo where m flag is enabled and makes $ match end of line positions, as in Visual Studio Code, and due to (?![\w\W]) it only matches at the very end of the text.

Upvotes: 2

Related Questions