{"id":13453639,"url":"https://github.com/SublimeText/TrailingSpaces","last_synced_at":"2025-03-24T01:31:40.228Z","repository":{"id":46183065,"uuid":"2595004","full_name":"SublimeText/TrailingSpaces","owner":"SublimeText","description":"Highlight trailing spaces and delete them in a flash.","archived":false,"fork":false,"pushed_at":"2023-06-24T20:48:51.000Z","size":108,"stargazers_count":896,"open_issues_count":12,"forks_count":95,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-03-19T02:04:47.186Z","etag":null,"topics":["sublime-text","sublime-text-package","sublime-text-plugin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SublimeText.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-10-17T21:13:05.000Z","updated_at":"2025-03-13T01:28:50.000Z","dependencies_parsed_at":"2024-10-28T20:34:43.283Z","dependency_job_id":"3e556a8d-027d-4f8b-8478-c63d5cc08ea5","html_url":"https://github.com/SublimeText/TrailingSpaces","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SublimeText%2FTrailingSpaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SublimeText%2FTrailingSpaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SublimeText%2FTrailingSpaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SublimeText%2FTrailingSpaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SublimeText","download_url":"https://codeload.github.com/SublimeText/TrailingSpaces/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245194264,"owners_count":20575731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sublime-text","sublime-text-package","sublime-text-plugin"],"created_at":"2024-07-31T08:00:44.835Z","updated_at":"2025-03-24T01:31:39.679Z","avatar_url":"https://github.com/SublimeText.png","language":"Python","funding_links":[],"categories":["Python","Editors","Extensions","Develop Tools"],"sub_categories":["Sublime Text 3","General Purpose","Case Study"],"readme":"Trailing Spaces\n===============\n\nA [Sublime Text](http://www.sublimetext.com) plugin that allows you to…\n\n**highlight trailing spaces and delete them in a flash!**\n\n---\n\n- [Synopsis](#synopsis)\n- [Installation](#installation)\n\t- [Alternative installation methods](#alternative-installation-methods)\n\t\t- [From github](#from-github)\n\t\t- [Manually](#manually)\n- [Usage](#usage)\n\t- [Deletion](#deletion)\n\t- [Toggling highlighting](#toggling-highlighting)\n- [Options](#options)\n\t- [Changing the highlighting color](#changing-the-highlighting-color)\n\t- [Keeping trailing spaces invisible](#keeping-trailing-spaces-invisible)\n\t- [Include Current Line](#include-current-line)\n\t- [Include Empty Lines](#include-empty-lines)\n\t- [Modified Lines Only](#modified-lines-only)\n\t- [Trim On Save](#trim-on-save)\n\t- [Save After Trim](#save-after-trim)\n\t- [Live Matching vs On-demand Matching](#live-matching-vs-on-demand-matching)\n\t- [Ignore Scope](#ignore-scope)\n\t- [For power-users only!](#for-power-users-only)\n\t\t- [Disabled for large files](#disabled-for-large-files)\n\t\t- [The matching pattern](#the-matching-pattern)\n- [About Sublime Text's built-in features](#about-sublime-texts-built-in-features)\n\nSynopsis\n--------\n\nSublime Text provides a way to automate deletion of trailing spaces *upon file\nsaving* (more on this at the end of this file). Depending on your settings, it\nmay be more handy to just highlight them and/or delete them by hand, at any\ntime. This plugin provides just that, and a *lot* of options to fine-tune the\nway you want to decimate trailing spaces.\n\nInstallation\n------------\n\nIt is available through\n[Sublime Package Control](http://wbond.net/sublime_packages/package_control) and\nthis is the recommended way of installation (brings configuration instructions,\nautomatic updates with changelogs…).\n\n### Alternative installation methods\n\n#### From github\n\nYou can install from github if you want, although Package Control automates\njust that. Go to your `Packages` directory (find out where it is by running\n`Preferences: Browse Packages` from The _Command Palette_) and clone this repository:\n\n    git clone https://github.com/SublimeText/TrailingSpaces.git\n\n#### Manually\n\n[Download](https://github.com/SublimeText/TrailingSpaces/archive/master.zip)\nthe plugin as a zip. Copy the *Trailing Spaces* directory to its location\n(see prior section).\n\nUsage\n-----\n\n### Deletion\n\nThe main feature you gain from using this plugin is that of deleting all\ntrailing spaces in the currently edited document. In order to use this\ndeletion feature, you may either:\n\n* click on \"Edit / Trailing Spaces / Delete\";\n* bind the deletion command to a keyboard shortcut:\n\nTo add a key binding, open \"Preferences / Key Bindings - User\" and add:\n\n``` js\n{ \"keys\": [\"ctrl+shift+t\"], \"command\": \"delete_trailing_spaces\" }\n```\n\nWith this setting, pressing \u003ckbd\u003eCtrl + Shift + t\u003c/kbd\u003e will delete all\ntrailing spaces at once in the current file! For OSX users, quoting wbond:\n\"When porting a key binding across OSes, it is common for the ctrl key on\nWindows and Linux to be swapped out for super on OS X\"\n(eg. use \"super+shift+t\" instead).\n\n*Beware*: the binding from this example overrides the default ST's mapping\nfor reopening last closed file. You can look at the default bindings in\n\"Preferences / Key Bindings - Default\".\n\n### Toggling highlighting\n\nAt any time, you can toggle highlighting on and off. You may either:\n\n- click on \"Edit / Trailing Spaces / Highlight Regions\"\n- bind the toggling command to a keyboard shortcut:\n\n``` js\n// I like \"d\", as in \"detect\" (overrides a default binding, though).\n{ \"keys\": [\"ctrl+shift+d\"], \"command\": \"toggle_trailing_spaces\" }\n```\n\nOptions\n-------\n\nSeveral options are available to customize the plugin's behavior. Those\nsettings are stored in a configuration file, as JSON. You must use a specific\nfile: Go to \"Preferences / Package Settings / Trailing Spaces / Settings\" to\nadd you custom settings.\n\nA few of them are also accessible through the \"Edit / Trailing Spaces\" menu.\nSometimes, editing a setting will require a fresh Sublime Text to be applied\nproperly, so try relaunching ST before reporting an issue ;)\n\nAll settings are global (ie. applied to all opened documents).\n\n### Changing the highlighting color\n\n*Default: \"invalid\"*\n\nYou may change the highlighting color, providing a color scope name such as\n \"error\", \"comment\"… just like that:\n\n``` js\n{ \"highlight_color\": \"comment\" }\n```\n\nThe scope should be defined in your current theme file. Here is a dummy,\nfully-fledged example (feel free to cut irrelevant pieces for your settings)\nof such a custom color scope:\n\n``` xml\n\u003cdict\u003e\n  \u003ckey\u003ename\u003c/key\u003e\n  \u003cstring\u003eInvalid - Illegal\u003c/string\u003e\n  \u003ckey\u003escope\u003c/key\u003e\n  \u003cstring\u003einvalid.illegal\u003c/string\u003e\n  \u003ckey\u003esettings\u003c/key\u003e\n  \u003cdict\u003e\n    \u003ckey\u003ebackground\u003c/key\u003e\n    \u003cstring\u003e#F93232\u003c/string\u003e\n    \u003ckey\u003efontStyle\u003c/key\u003e\n    \u003cstring\u003e\u003c/string\u003e\n    \u003ckey\u003eforeground\u003c/key\u003e\n    \u003cstring\u003e#F9F2CE\u003c/string\u003e\n  \u003c/dict\u003e\n\u003c/dict\u003e\n```\n\nYou would then use the value of \"invalid.illegal\".\n\n### Keeping trailing spaces invisible\n\nYou can make trailing spaces \"invisible\" yet still rely on the deletion\ncommand. To do that, set the highlight scope to an empty string:\n\n``` js\n{ \"highlight_color\": \"\" }\n```\n\nBeware: this is **not** the same as *disabling* the highlighting (see \"On-\nDemand Matching\" below). With this setting, the plugin still runs when opening\na file, and in the background afterwards; you just won't see the trailing\nspaces (they are being highlighted with a \"transparent\" color).\n\n### Include Current Line\n\n*Default: true*\n\nHighlighting of trailing spaces in the currently edited line can be annoying:\neach time you are about to start a new word, the space you type is matched as\na trailing spaces. Currently edited line can thus be ignored:\n\n``` js\n{ \"include_current_line\": false }\n```\n\nEven though the trailing spaces are not highlighted on this line, they are\nstill internally matched and will be delete when firing the deletion command.\n\n### Include Empty Lines\n\n*Default: true*\n\nWhen firing the deletion command, empty lines are matched as trailing regions,\nand end up being deleted. You can specifically ignore them:\n\n``` js\n{ \"include_empty_lines\": false }\n```\n\nThey will not be highlighted either.\n\n### Modified Lines Only\n\n*Default: false (reopen ST to update)*\n\nWhen firing the deletion command, trailing regions *in the entire document* are\ndeleted. There are some use-cases when deleting trailing spaces *only on lines\nyou edited* is smarter; for instance when commiting changes to some third-party\nsource code.\n\nAt any time, you can change which area is covered when deleting trailing\nregions. You may either:\n\n- click on \"Edit / Trailing Spaces / Modified Lines Only\"\n- specify as a setting:\n\n``` js\n{ \"modified_lines_only\": true }\n```\n\nThere is also a command to toggle this feature on and off. You may thus define\na key binding:\n\n``` js\n{ \"keys\": [\"pick+a+shortcut\"], \"command\": \"toggle_trailing_spaces_modified_lines_only\" }\n```\n\n### Trim On Save\n\n*Default: false*\n\nSetting this to `true` will ensure trailing spaces are deleted when you save\nyour document. It abides by the other settings, such as *Modified Lines Only*.\n\n``` js\n{ \"trim_on_save\": true }\n```\n\n### Save After Trim\n\n*Default: false*\n\nYou may not want to always trim trailing spaces on save, but the other way\naround could prove useful. Setting this to `true` will automatically save your\ndocument after you fire the deletion command:\n\n``` js\n{ \"save_after_trim\": true }\n```\n\nIt is obviously ignored if *Trim On Save* is on.\n\n### Live Matching vs On-demand Matching\n\n*Default: true (reopen ST to update)*\n\nBy default, trailing regions are matched every time you edit the document, and\nwhen you open it.\n\nThis feature is entirely optional and you may set it off: firing the deletion\ncommand will cause the trailing spaces to be deleted as expected even though\nthey were not matched prior to your request. If you are afraid of the plugin\nto cause slowness (for instance, you already installed several *heavy*\nplugins), you can disable live matching:\n\n``` js\n{ \"enabled\": false }\n```\n\nIn this case, for no trailing regions are matched until you request them to be\ndeleted, no highlighting occurs—it is in fact disabled, regardless of your\n\"scope\" setting. If you want to check the trailing spaces regions, you can\ntoggle highlighting on and off. In this case, it may come in handy to define\na binding for the toggling command. When \"On-demand Matching\" is on and some\ntrailing spaces are highlighted, added ones will obviously not be. Toggling\nhighlight off and on will refresh them.\n\n### Ignore Scope\n\n*Default: [\"text.find-in-files\", \"source.build_output\", \"source.diff\", \"text.html.markdown\"]*\n\nWith this option you can ignore lines being highlighted based on the scope of\ntheir trailing region.\n\nIf at least one scope in the configured list matches a scope in the trailing\nregion of the line, it won't be highlighted.\n\nBy default, the scope under the mouse cursor is shown by pressing\n`Option+Command+P` (OS X) or `Ctrl+Alt+Shift+P` (Windows, Linux)\n\n``` js\n// Trailing spaces for Find Results, Build output, Diff and Markdown are ignored\n{ \"scope_ignore\": [\"text.find-in-files\", \"source.build_output\", \"source.diff\", \"text.html.markdown\"] }\n```\n\n### For power-users only!\n\n#### Disabled for large files\n\nThe plugin is disabled altogether for large files, for it may cause slowness.\nThe default threshold is around 1 million of characters. This is\nconfigurable (in \"File Settings - User\") and the unit is number of chars:\n\n``` js\n{ \"file_max_size\": 1000}\n```\n\n#### The matching pattern\n\n*Default: [ \\t]+*\n\nTrailing spaces are line-ending regions containing at least one simple space,\ntabs, or both. This pattern should be all you ever need, but if you *do* want\nto abide by another definition to cover edge-cases, go ahead:\n\n``` js\n// *danger* will match newline chars and many other folks\n\"regexp\": \"[\\\\s]+\"\n```\n\nAbout Sublime Text's built-in features\n--------------------------------------\n\nTrailing Spaces is designed to be a drop-in replacement of the limited\n*Trim Whitespace On Save* built-in feature. ST is indeed able to delete\ntrailing spaces upon saving files, and maybe that's all you need!\n\nIn order to enable this behavior, edit \"Preferences / Settings\"\nto add the following:\n\n``` js\n{ \"trim_trailing_white_space_on_save\": true }\n```\n\nAs Trailing Spaces bypasses this setting, you will have to uninstall it to\nbenefit from this setting.\n\nMade a little less obvious in the documentation are settings to showcase\nwhitespaces (*not only trailing ones!*):\n\n``` js\n{ \"draw_white_space\": \"all\" }\n```\n\nand to ensure a newline is kept at end of file upon saving:\n\n``` js\n{ \"ensure_newline_at_eof_on_save\": true }\n```\n\nThe former will display *all* whitespaces in your files. There is another value\nof \"selection\" which display whitespaces under (you got it) your current text\nselection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSublimeText%2FTrailingSpaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSublimeText%2FTrailingSpaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSublimeText%2FTrailingSpaces/lists"}