All Projects → shardulm94 → vscode-trailingspaces

shardulm94 / vscode-trailingspaces

Licence: MIT license
A VS Code extension that allows you to highlight trailing spaces and delete them in a flash!

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vscode-trailingspaces

Vscode Notion
Browse Notion pages right inside Visual Studio Code.
Stars: ✭ 204 (+277.78%)
Mutual labels:  vscode-extension
Vscode Jupyter
VS Code Jupyter extension
Stars: ✭ 216 (+300%)
Mutual labels:  vscode-extension
vim-strip-trailing-whitespace
🎞️ Vim plugin that removes trailing whitespace from *modified* lines on save
Stars: ✭ 66 (+22.22%)
Mutual labels:  trailing-spaces
Svelte Vscode
Svelte language support for VS Code
Stars: ✭ 211 (+290.74%)
Mutual labels:  vscode-extension
Ghosttext
👻 Use your text editor to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).
Stars: ✭ 2,614 (+4740.74%)
Mutual labels:  vscode-extension
Vscode Comment Translate
vscode 注释翻译插件, 不干扰正常代码,方便快速阅读源码。
Stars: ✭ 235 (+335.19%)
Mutual labels:  vscode-extension
Metals Vscode
Visual Studio Code extension for Metals
Stars: ✭ 200 (+270.37%)
Mutual labels:  vscode-extension
Netlify
A VS Code extension that displays your Netlify build statuses and more!
Stars: ✭ 23 (-57.41%)
Mutual labels:  vscode-extension
Typescript Hero
VSCode extension that assists you with your everyday work around typescript
Stars: ✭ 222 (+311.11%)
Mutual labels:  vscode-extension
Vscode Deno
[Deprecated] Move to https://github.com/denoland/vscode_deno
Stars: ✭ 249 (+361.11%)
Mutual labels:  vscode-extension
Code Blue
A carefully concocted dark theme made of subtle blues and bright hues that’s easy on the eyes for focused coding.
Stars: ✭ 215 (+298.15%)
Mutual labels:  vscode-extension
Vscode One Monokai
🎨 Vscode One Monokai theme.
Stars: ✭ 214 (+296.3%)
Mutual labels:  vscode-extension
Styled Ppx
Typed styled components in Reason, OCaml and ReScript
Stars: ✭ 236 (+337.04%)
Mutual labels:  vscode-extension
Vs Picgo
A VSCode plugin of PicGo
Stars: ✭ 209 (+287.04%)
Mutual labels:  vscode-extension
vim-high
Vim plugin: All-in-one highlighter, highlight custom pattern like indentation, inactive window, word under the cursor
Stars: ✭ 20 (-62.96%)
Mutual labels:  trailing-spaces
Abracadabra
Automated refactorings for VS Code (JS & TS) ✨ It's magic ✨
Stars: ✭ 204 (+277.78%)
Mutual labels:  vscode-extension
Vshaxe
Haxe Support for Visual Studio Code
Stars: ✭ 234 (+333.33%)
Mutual labels:  vscode-extension
unotes
Unotes Visual Studio Code Extension. A markdown WYSIWYG notes editor.
Stars: ✭ 137 (+153.7%)
Mutual labels:  vscode-extension
vscode-R
R Extension for Visual Studio Code
Stars: ✭ 788 (+1359.26%)
Mutual labels:  vscode-extension
Vscode Live Server
Launch a development local Server with live reload feature for static & dynamic pages.
Stars: ✭ 3,275 (+5964.81%)
Mutual labels:  vscode-extension

Trailing Spaces

Build Status VS Code Marketplace Rating Installs

A VS Code extension that allows you to…

highlight trailing spaces and delete them in a flash!

This extension is a port of the popular Sublime Text plugin Trailing Spaces.


Synopsis

VS Code provides a way to automate deletion of trailing spaces by using the Trim Trailing Whitespace command. Depending on your settings, it may be more handy to just highlight them and/or delete them by hand, at any time. This plugin provides just that, and a lot of options to fine-tune the way you want to decimate trailing spaces.

Installation

It is available through Visual Studio Marketplace and this is the recommended way of installation (brings integrated updates).

Usage

Delete

The main feature you gain from using this plugin is that of deleting all trailing spaces in the currently edited document. In order to use this deletion feature, you may either:

  • press F1 and select/type "Trailing Spaces: Delete"
  • bind the deletion command to a keyboard shortcut:

To add a key binding, open "File / Preferences / Keyboard Shortcuts" and add:

{ "key": "alt+shift+t",        "command": "trailing-spaces.deleteTrailingSpaces",
                                  "when": "editorTextFocus" },

With this setting, pressing Alt + Shift + t will delete all trailing spaces at once in the current file!

Delete - Modified Lines Only

You can also delete the trailing spaces exclusively from the modified (unsaved) lines. In order to use this deletion feature, you may either:

  • press F1 and select/type "Trailing Spaces: Delete - Modified Lines Only"
  • bind the deletion command to a keyboard shortcut:

To add a key binding, open "File / Preferences / Keyboard Shortcuts" and add:

{ "key": "alt+shift+m",        "command": "trailing-spaces.deleteTrailingSpacesModifiedLinesOnly",
                                  "when": "editorTextFocus" },

Highlight

At any time, you can highlight the trailing spaces. You may either:

  • press F1 and select/type "Trailing Spaces: Highlight"
  • bind the highlighting command to a keyboard shortcut:
{ "key": "alt+shift+h",        "command": "trailing-spaces.highlightTrailingSpaces",
                                  "when": "editorTextFocus" },

Options

Several options are available to customize the plugin's behavior. Those settings are stored in a configuration file, as JSON. You must use a specific file: Go to "File / Preferences / User Settings" to add your custom settings.

All settings are global (ie. applied to all opened documents).

Highlight Current Line

Default: true

Highlighting of trailing spaces in the currently edited line can be annoying: each time you are about to start a new word, the space you type is matched as a trailing spaces. Currently edited line can thus be ignored:

{ "trailing-spaces.highlightCurrentLine": false }

Even though the trailing spaces are not highlighted on this line, they are still internally matched and will be deleted when firing the deletion command. If you are editing multiple lines (using multiple cursors), all such lines will be ignored.

Include Empty Lines

Default: true

When firing the deletion command, empty lines are matched as trailing regions, and end up being deleted. You can specifically ignore them:

{ "trailing-spaces.includeEmptyLines": false }

They will not be highlighted either.

Note: This option only deletes the trailing spaces in blank lines and not the whole line itself. If you want to delete the newline character as well, please consider changing the regex.

Delete Modified Lines Only

Default: false

When firing the deletion command, trailing regions in the entire document are deleted. There are some use-cases when deleting trailing spaces only on lines you edited is smarter; for instance when commiting changes to some third-party source code.

At any time, you can change which area is covered when deleting trailing regions by changing the setting:

{ "trailing-spaces.deleteModifiedLinesOnly": true }

Trim On Save

Default: false

Setting this to true will ensure trailing spaces are deleted when you save your document. It abides by the other settings, such as Include Empty Lines.

{ "trailing-spaces.trimOnSave": true }

Save After Trim [REMOVED]

NOTE: The current VSCode lifecycle for text editor commands does not provide a clean way to implement this feature. Since I did not see a lot of folks using this option, it was better to remove it.

Default: false

You may not want to always trim trailing spaces on save, but the other way around could prove useful. Setting this to true will automatically save your document after you fire the deletion command:

{ "trailing-spaces.saveAfterTrim": true }

It is obviously ignored if Trim On Save is on.

Live Matching vs On-demand Matching

Default: true (reload VS Code Window to update)

By default, trailing regions are matched every time you edit the document, and when you open it.

This feature is entirely optional and you may set it off: firing the deletion command will cause the trailing spaces to be deleted as expected even though they were not matched prior to your request. If you are afraid of the plugin to cause slowness (for instance, you already installed several heavy extensions), you can disable live matching:

{ "trailing-spaces.liveMatching": false }

In this case, for no trailing regions are matched until you request them to be deleted, no highlighting occurs—it is in fact disabled. If you want to check the trailing spaces regions, you can use the Highlight Trailing Spaces command. In this case, it may come in handy to define a binding for the highlighting command. When "On-demand Matching" is on and some trailing spaces are highlighted, added ones will obviously not be. Running the highlight command again will refresh them.

Ignore Syntax

Default: []

With this option you can ignore specific files based on the language used. An item has to match the case-sensitive string of the language used in the file:

// files with the language "markdown" are ignored
{ "trailing-spaces.syntaxIgnore": ["markdown"]}

Here is a list of all languages that VS Code supports (as of 28 March 2019):

bat, c, clojure, coffeescript, cpp, csharp, css, diff, dockerfile, fsharp, git-commit, git-rebase, go, groovy, handlebars, hexdump, hlsl, hocon, html, ignore, ini, jade, java, javascript, javascriptreact, jinja, json, jsonc, jsx-tags, jupyter, less, Log, log, lua, makefile, markdown, objective-c, objective-cpp, perl, perl6, php, pig, pip-requirements, plaintext, powershell, properties, python, r, razor, ruby, rust, scss, shaderlab, shellscript, sql, swift, toml, typescript, typescriptreact, vb, xml, xsl, yaml

For the most recent list of langauges, please use the known language identifiers page or the languages.getLanguages() function (details here).

Ignore Scheme

Default: ["output"]

With this option you can ignore documents with a specific scheme. An item has to match the case-sensitive string of the scheme of the document. For instance, if you want to ignore VSCode output windows:

// documents with the scheme "output" are ignored
{ "trailing-spaces.schemeIgnore": ["output"]}

Show Status Bar Message

Default: true

By default, trailing space deletions will be communicated through a status bar message. Set this to false as below to disable these messages:

{ "trailing-spaces.showStatusBarMessage": false }

Background Color

Default: rgba(255,0,0,0.3)

You can control the background color of the highlighting performed by Trailing Spaces using this option. To set up another color change the setting:

{ "trailing-spaces.backgroundColor": "rgba(255,0,0,0.3)" }

To make the highlighting invisible, set this and the border color properties to transparent.

Border Color

Default: rgba(255,100,100,0.15)

You can control the border color of the highlighting performed by Trailing Spaces using this option. To set up another color change the setting:

{ "trailing-spaces.borderColor": "rgba(255,100,100,0.15)" }

To make the highlighting invisible, set this and the background color properties to transparent.

For power-users only!

The matching pattern

Default: [ \t]+

Trailing spaces are line-ending regions containing at least one simple space, tabs, or both. This pattern should be all you ever need, but if you do want to abide by another definition to cover edge-cases, go ahead:

// *danger* will match newline chars and many other folks
"trailing-spaces.regexp": "[\\s]+"

Contributions

  • @HookyQR: Fixed error while deleting last line of text PR #9
  • @yustnip: Added options to change background and border colors of highlighting PR #17
  • @ameily: Properly trim spaces using the new TextEditor.edit() callback PR #26
  • @mplellison: Restructure tests for maintainability and ensure consecutive modified lines are trimmed PR #44
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].