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 3K
  • Win 2K
  • Mac 1K
  • Linux 397
Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13
Windows 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 1 0 1 1 1 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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.