ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Trimmer

by jonlabelle ST2/ST3

A Sublime Text plug-in for cleaning up whitespace.

Details

Installs

  • Total 122K
  • Win 75K
  • OS X 28K
  • Linux 20K
Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12
Windows 30 42 37 28 31 34 49 43 34 46 32 28 41 44 48 55 79 32 27 42 41 48 46 45 23 26 47 54 45 46 39 29 33 38 40 46 42 46 25 22 43 42 33 36 30 30
OS X 5 13 13 5 5 12 4 13 10 7 5 9 9 8 16 16 5 7 4 12 15 9 19 15 13 5 10 9 13 6 9 5 5 18 6 12 9 14 12 6 10 12 5 11 12 7
Linux 7 8 11 1 9 14 9 10 8 11 7 2 11 12 9 9 9 6 3 9 9 11 19 13 7 8 8 13 13 5 7 8 2 11 5 10 12 10 7 9 14 9 5 6 12 5

Readme

Source
raw.​githubusercontent.​com

Trimmer

Travis CI Build Status AppVeyor Build status Package Control Installs Latest Release

Trimmer is a Sublime Text plug-in for cleaning up whitespace.

Features

  • Trim whitespace at the end of each line.
  • Trim whitespace at the start of each line.
  • Trim whitespace at the start and end of each line.
  • Trim whitespace from selection(s).
  • Delete empty, whitespace only lines.
  • Collapse multiple consecutive empty lines into one empty line.
  • Collapse multiple consecutive spaces into one space.
  • Trim empty, whitespace only lines at the beginning and end of file.
  • Remove blank space characters.
  • Normalize spaces (consecutive spaces reduced, empty lines removed and lines trimmed).
  • Tokenize a string by collapsing consecutive spaces, and trimming leading and trailing spaces.
  • Delete empty, whitespace only HTML and XML tags.
  • Remove code comments and collapse lines.

Additional Features

A Replace Smart Characters command that performs the following actions:

  • Smart single quotes: to '
  • Smart double quotes: to "
  • Prime: to '
  • Double Prime: to "
  • German quotes: to " and to '
  • Ellipsis: to ...
  • Em dash: to ---
  • En dash: to --
  • Bullet: to *
  • Middle dot: · to -
  • Em space to three spaces
  • En space to two spaces
  • Non-breaking space to one space
  • Thin space to one space
  • Hair space to one space
  • Left angle quote: « to <<
  • Right angle quote: » to >>
  • Copyright symbol: © to (C)
  • Trademark symbol: to (T)
  • Registered trademark symbol: ® to (R)

ScreenShot

Watch a Quick Demo

Install

Trimmer is compatible with both Sublime Text 2 and 3 and all supported Operating Systems.

Package Control

The easiest, and recommended way to install Trimmer is using Package Control.

From the main application menu, navigate to:

  • Tools -> Command Palette... -> Package Control: Install Package, type the word Trimmer, then select it to complete installation.

Git

To install Trimmer using Git, change to your Sublime Text Packages directory and clone the Trimmer repository.

For example, on OS X… start a new Terminal session and enter the following commands:

$ cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/
$ git clone https://github.com/jonlabelle/Trimmer

Manually

Download and extract the zip or tarball to your Sublime Text packages directory.

Default Sublime Text Packages Paths:

  • OS X: ~/Library/Application Support/Sublime Text [2|3]/Packages
  • Linux: ~/.Sublime Text [2|3]/Packages
  • Windows: %APPDATA%/Sublime Text [2|3]/Packages

NOTE Replace the [2|3] part with the appropriate Sublime Text version for your installation.

Usage

All commands are accessible from the Command Palette using prefix Trimmer, and in the Main Menu under Edit -> Line -> Trimmer command.

Key Bindings

The default key binding will trim trailing whitespace at the end of each of line (entire file).

  • OS X: Ctrl + S
  • Linux: Ctrl + Alt + S
  • Windows: Ctrl + Alt + S

Trimmer Command API

Command Description Context
trimmer trim whitespace at the end of each line entire file
trim_leading_whitespace trim whitespace at the start of each line selection, or entire file
trim_leading_trailing_whitespace trim whitespace at the start and end of each line selection, or entire file
trim_selections trim whitespace from selection(s) selection
delete_empty_lines delete empty, whitespace only lines selection, or entire file
collapse_lines collapse multiple consecutive empty lines into one empty line selection, or entire file
collapse_spaces collapse multiple consecutive spaces into one space selection, or entire file
trim_edges trim empty, whitespace only lines at the beginning and end of the file entire file
remove_blank_spaces remove all blank space characters (tab, cr, ff, vt, space) selection, or entire file
normalize_spaces consecutive spaces reduced, empty lines removed and lines trimmed selection, or entire file
replace_smart_characters replace smart characters (smart quotes, em/en dash, ellipsis, nbsp) selection, or entire file
tokenize_string convert a string to a token by collapsing consecutive spaces, and trimming leading and trailing spaces selection, or entire file
delete_empty_tags delete empty, whitespace only html and xml tags selection, or entire file
remove_comments remove code comments and collapse lines selection, or entire file

Author

Jon LaBelle

License

Trimmer is licensed under the MIT license.