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

Unused​Css​Finder

by Harderer ST3

Sublime Text 3 plugin to find unused css names

Labels css, search

Details

Installs

  • Total 2K
  • Win 1K
  • OS X 604
  • Linux 191
Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3 Jul 2 Jul 1 Jun 30 Jun 29 Jun 28 Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6
Windows 0 3 4 0 1 1 0 2 1 0 0 0 3 0 1 0 0 2 2 3 0 1 0 1 1 3 2 0 3 0 2 3 0 2 0 1 5 0 2 2 1 1 2 3 1 2
OS X 0 0 1 0 0 3 2 1 0 0 0 3 1 0 0 1 1 1 0 2 0 0 2 2 0 1 1 0 0 1 2 0 0 1 0 2 2 1 1 0 2 0 0 2 0 0
Linux 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0

Readme

Source
raw.​githubusercontent.​com

UnusedCssFinder-Sublime

Only supports Sublime Text 3.

Sublime plugin to find unused css names

Author: Jannis Harder: jannisharder@hotmail.de

Last modified: 15 August 2016

Plugin to find unused css declarations in a project. Searches for all id and class names inside current open project or file directory if no project is currently open. All css names that do not occur once in any other .php, .html, .xhtml or .js file will be selected.

Default

Might run slow on big projects, do not hesitate to send me improvement recommendations as this is my first sublime plugin.

Usage

Inline CSS: Open the file and press ctrl + u + f to find css declarations without any occurence in the current file.

Extern CSS: Open any *.css file and press ctrl + u + f to find css declarations without any occurence in the current project. If no project is active, the search takes place at the css file location.

Default Key Bindings

for Mac:

{ "keys": ["super+u", "super+f"], "command": "unused_css_finder"}

for Windows/Linux:

{ "keys": ["ctrl+u", "ctrl+f"], "command": "unused_css_finder"}

Settings

  • unused_css_root_folder: define a projects root location if ti deviates from the sublime projects root location.
  • unused_css_ignore_folders: any folder added here will be ignored in the search for occurences of the css names.
  • unused_css_scan_only_folders: if you want to search explicitly in only some folder, define them here and a search will only happen in a folder, it its name is in this list. Important: Add them as object with the folders being the keys and a boolean as value. The boolean defines, if all subfolders in this folder are allowed to be included in the search.
  • unused_css_ignore_selectors*: define any selectors, that should be ignored in the search. Can be defined with class or id selcetor or as plain selector name. (e.g. “#example”, “.example” or “example”)
  • unused_css_highlight_selectors*: if true, the found selectors won't be selected via cursor but highlighted. The highlighting can be removed by running the same command again.

Highlighting

  • unused_css_delete_on_search*: deletes all unused selectors after search if true. Be sure to add composited html classes and ids to the ignored selectors list. e.g. if you have a class declaration like “test_”+true_or_false, add “test_false” and “test_true” to ignore - they would be deleted otherwise.

AutoDelete

*All these settings can be configured over the context menu on right click also. Clicking “Add To Selectors Ignore List” will add all selected elements to the list.

Project Settings

You can also define all the above settings in an individual “unused_css.cfg” file for each project, that needs to be located in the projects rootpath. All settings in the file will be appended to the default/user settings or override the settings, if it's a boolean value.

Change Log

v1.3.3

  • fixed a bug for combinator selectors

v1.3.2

  • Optimized the way, unused css declarations are selected.
  • Clean selection/deletion in multiple declarations

v1.3.1

  • fixed a bug for inline css

v1.3.0

  • settings can now be configured over a project specific file “unused_css.cfg” that has to be located in a projects root path
  • added 'unused_css_ignore_selectors' setting: Every element in this array will be ignored in the search and never be stated as non occured selector. Can also be defined as id or class selector, e.g. “#example”, “.example”, “example”
  • added 'unused_css_delete_on_search' setting: Every unused css selector that was found during the search will be removed after the search
  • switched default behaviour of plugin. Instead of highlighting every unused selector, they will be selected via cursor, to be able to remove them with one backspace press
  • added 'unused_css_highlight_selectors' setting: switch to old behaviour, that unused selectors will be highlighted instead of selected via cursor
  • added plugin to sublime context menu on right click to be able to configure some settings and also run the command without shortcut
  • most of these changes are based on the ideas from NoxNoctis2, thanks for that

v1.2.2

  • optimized the search patterns to only find the exact selector names and no words where they occur as substring

v1.2.1

  • fixed a bug in the plugin default settings file
  • added debugging functionality

v1.2.0

  • the plugin now works for inline css as well
  • added configuration path into sublime menu: “Preferences/Package Settings/UnusedCssFinder/”
  • Added default key bindings to the project

v1.1.0

  • Added settings to define folders, in which the search takes place
  • Fixed a bug to truely search asynchronously

License

This work is licensed under the The MIT License.