How to make vim alphabetically sort CSS rules within a single line?

后端 未结 3 1927
别那么骄傲
别那么骄傲 2021-02-10 15:35

Source:

.foo { line-height: 150px; font-size: 24px; clear: both; }

vim magic here, probably something visual selection based

R

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-10 15:38

    :s/\([{;]\)\s*/\1\r/g | '[+1,']sort | '[,']join
    

    Split the line on { or ; to get each rule into a separate line, :sort them (omitting the first line containing the CSS definition), then join them back together.

提交回复
热议问题