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 108K
  • Win 66K
  • OS X 25K
  • Linux 17K
Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30
Windows 36 38 52 44 28 39 49 47 70 53 59 34 18 27 55 46 52 56 24 30 38 39 45 47 48 23 35 45 50 37 60 55 32 45 44 46 44 38 46 23 22 51 65 53 36 61
OS X 6 16 7 15 7 11 11 10 17 20 17 7 8 21 13 11 11 24 4 9 7 14 18 9 17 8 12 14 12 16 16 19 9 10 15 16 10 11 8 5 12 25 9 11 16 12
Linux 11 17 12 13 5 6 9 12 7 12 13 8 4 11 13 8 17 14 9 4 13 16 14 12 13 9 10 10 15 12 17 19 6 9 9 16 21 14 13 13 14 7 15 11 13 14

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 "
  • German quotes: to " and to '
  • Ellipsis: to ...
  • Em dash: to ---
  • En dash: to --
  • Middle dot: to *
  • Bullet: · 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.