Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
Removing Empty Lines
To remove empty lines from a file:
- Open Find and Replace (
cmd-H) - Enable regex mode (click the
.*icon) - Search for
\n\nand replace with\n - Run “Replace All”
You may need to run it multiple times until you get down to single empty lines.
Pro tip: Use \n\n+ to replace all consecutive empty lines at once without repeating the operation.
Search and Replace with Regular Expressions
VS Code supports powerful regex-based find and replace. Here’s a real-world example:
Example: Wrapping Image Paths with Special Characters
Suppose you need to update image links with spaces in their filenames:

to:

Use this regex to find images with spaces:
!\[(.+)\]\((.*\s+.*)\)
This creates two capturing groups:
$1- the alt text$2- the filename
Then use this replacement:

For images without alt text, use:
!\[\]\((.*\s+.*)\)
With replacement:

Testing Regex
Use regex101.com to quickly test your regular expressions before using them in VS Code.