How to Remove Trailing Spaces in Visual Studio Code(VS Code)

remove-trailing-spaces-vs-code-feature-image

A Developer asked on Stackoverflow platform : –

Is there a way to remove trailing spaces in Visual Studio Code (automatically or with a shortcut)?

The solution to this problem is simple:

Solution 1

Go to FilePreferenceSettings → search for “trim”:

Check the “Trim Trailing Whitespace” option – “When enabled, will trim trailing whitespace when saving a file”.

Solution 2

Not only can you change the Visual Studio Code settings to trim trailing whitespace automatically, but you can also do this from the command palette (Ctrl+Shift+P):

Solution 3

You can also use the keyboard shortcut:

Windows, Linux: Ctrl+K, Ctrl+X
Mac: ⌘ + k, ⌘ + x.

Resources

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

Similar articles you may like

By Sunil Pradhan

Hi there 👋 I am a front-end developer passionate about cutting-edge, semantic, pixel-perfect design. Writing helps me to understand things better.

Leave a comment

Your email address will not be published. Required fields are marked *

Exit mobile version