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

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

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 File β†’ Preference β†’ Settings β†’ search for “trim”:

remove-trailing-spaces-vs-code-img-1

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):

remove-trailing-spaces-vs-code-img-2

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.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Similar articles you may like

Sunil Pradhan

Hi there πŸ‘‹ My name is Sunil and I'm a front-end developer who loves to help others by simplifying web-dev related topics.

Add comment

Stay Updated

Want to be notified when our article is published? Enter your email address below to be the first to know.

Sunil Pradhan

Hi there πŸ‘‹ My name is Sunil and I'm a front-end developer who loves to help others by simplifying web-dev related topics.