Skip to main content

CSS Property Sorter Script

Project description

# CSS Property Sorter Script

## Installation

pip install sortcss.py

### Setup for Vim

1. Create `~/.vim/ftplugin/css.vim` if it's not existed yet.
2. Open `~/.vim/ftplugin/css.vim` and add new lines below:

```vim
" CSS Property Sorter Script (:SortCSS to run)
command! -range=% -nargs=* SortCSS :<line1>,<line2>!python /path/to/sortcss.py <f-args>
```

## Usage

### Command-line options

usage: sortcss.py [-h] [-g] [--css-props-file [CSS_PROPS_FILE]]
[INFILE] [OUTFILE]

positional arguments:
INFILE Input file
OUTFILE Output file

optional arguments:
-h, --help show this help message and exit
-g, --group group properties
--css-props-file [CSS_PROPS_FILE]
use custom CSS properties list file

#### CSS properties list file

You can use custom list by supplying the file to `sortcss.py`, the basic format is:

# comment
margin
padding

background
color

The order of properties is the order that`sortcss.py` sort by and the blank line also indicates separate groups. If you have `-g`, then `sortcss.py` will insert a blank line between the groups.

### Usage in Vim

1. Open a CSS file in Vim.
2. Turn in to Visual mode.
3. Select CSS definition(s). At least 1 set of `{` to `}`.
4. Type `:SortCSS` and return.

This will automatically sort your CSS properties.

#### Notes

* You can just type `:SortCSS` so that entire properties will be sorted in a file.
* You can also append arguments as if using `sortcss.py` directly, e.g. `:SortCSS -g` for grouping.

## Credits

You can find more information about the script below:
http://lab.youck.org/css-property-order.html

This script is based on Kyo Nagashima's Perl script:
http://hail2u.net/blog/coding/perl-sort-css-properties.html

* Yu-Jie Lin, http://yjl.im
* Yu I., Twitter @japboy
* Kyo Nagashima <kyo@hail2u.net>, http://hail2u.net/
* xaicron, http://blog.livedoor.jp/xaicron/

## License

MIT License, see COPYING

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

sortcss.py-0.1.2.zip (14.2 kB view details)

Uploaded Source

sortcss.py-0.1.2.tar.gz (7.9 kB view details)

Uploaded Source

sortcss.py-0.1.2.tar.bz2 (7.6 kB view details)

Uploaded Source

File details

Details for the file sortcss.py-0.1.2.zip.

File metadata

  • Download URL: sortcss.py-0.1.2.zip
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sortcss.py-0.1.2.zip
Algorithm Hash digest
SHA256 2a8c18f75501417062209f09b966f27141fcd355b01c4acb5450351d01d2c503
MD5 9ff7ec7f1fc80144bdabada0e36aa8b8
BLAKE2b-256 8314d5deedfaf2fe7b78f8c3ebad9452b6e2a32885881fbf38455a320a501259

See more details on using hashes here.

File details

Details for the file sortcss.py-0.1.2.tar.gz.

File metadata

  • Download URL: sortcss.py-0.1.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sortcss.py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 72521e5c708b21f23c6ccdf4fce72b97daa1b7df1873aae6cede502c4e5c0a27
MD5 595048697276a4475d793fcdbc8ab2ed
BLAKE2b-256 66c0c36f62db07c2efecdd3441168b008d326a66989767e0018fb4af9030987e

See more details on using hashes here.

File details

Details for the file sortcss.py-0.1.2.tar.bz2.

File metadata

  • Download URL: sortcss.py-0.1.2.tar.bz2
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sortcss.py-0.1.2.tar.bz2
Algorithm Hash digest
SHA256 92f642190c2e3e9fc7ac42a84b90b485722a6a90bb88ff2ec8976d782937f537
MD5 1d908674beb1b903a5179ba3defd96ed
BLAKE2b-256 bb5bea012d7d7600869de7cba12ac07b6a912dd2a635d3127a6f12cf048b9a18

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page