Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Trailing Whitespace FixerNew to Visual Studio Code? Get it now.
Trailing Whitespace Fixer

Trailing Whitespace Fixer

Stephen Sigwart

|
4,095 installs
| (0) | Free
Automatically removes trailing whitespace when you hit Enter. Also highlights trailing whitespace.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Trailing Whitespace Fixer

This extension helps to identify and remove trailing whitespace. It includes the following features:

Trim on Enter

  • If you hit Enter on a line that has trailing whitespace, it will be automatically removed.

  • If you hit Enter before whitespace on a line, the whitespace will be removed.

    Example: The | character represents the cursor position.

      $arr = [
      	1, 2,| 3, 4
      ];
    

    Hitting Enter without Extension

      $arr = [
      	1, 2,
      	| 3, 4
      ];
    

    Hitting Enter with Extension

      $arr = [
      	1, 2,
      	|3, 4
      ];
    

Show Trailing Whitespace

  • Any trailing whitespace on lines other than the current line will be highlighted in red.

Configuration

  • If you want to allow lines that are only whitespace, you can enable the trailing-whitespace-fixer.allowWhitespaceOnlyLines setting. This is useful if you want to retain the current indentation level.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft