Skip to content
mnaoumov.dev
Go back

Regex to find the end of file (EOF) in Visual Studio Code

Hi folks.

To do bulk text replacement, I usually use Visual Studio Code. I needed to replace some text only if it is at the end of the file (EOF). But simple regex $ would not work, because it finds end of each line. It seems that in VSCode they use multiline regex. And I didn’t find how to switch those regex settings.

So I came up with more difficult regex for that purpose

$(?!.|\n)

It means the end of line which is not followed by any character or newline, so the only end of file (EOF) will be found.

Stay tuned!

UPD: Actually, the simpler regex is enough $(?!\n)


Share this post on:

Previous Post
Switch between three keyboard languages
Next Post
PowerShell Predictive IntelliSense