Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAindriu Mac Giolla Eoin
2,056 PointsIs there a shortcut to remove extra line spaces (more than 1) in Visual Studio
In my code I often have more than 1 line space in between lines of code. Is there a keyboard shortcut to remove them?
I read the following but was unsure if it would ruin my code:
- Click Ctrl+H (quick replace)
- Tick "Use Regular Expressions"
- In Find specify "^$\n"
- In Replace box delete everything.
- Click "Replace All"
2 Answers
Steven Parker
231,184 PointsIt looks like it would work.
I use the VsVim plug-in so I would do this differently. But it seems like it should work, since the regular expression would only match lines that have no content. If you also want to remove lines that have nothing but whitespace, you could try this expression in the Find
box instead ^\s*$\n
If you're concerned about "ruining" a file, just make a copy of the file first using the explorer or command line. Then you can overwrite it with your copy in case a Control-Z doesn't undo everything as it should.
Aindriu Mac Giolla Eoin
2,056 PointsIt works perfect thanks !