如何使vim按字母顺序在一行内排序CSS规则? [英] How to make vim alphabetically sort CSS rules within a single line?
问题描述
资料来源:
.foo {line-height:150px; font-size:24px;清除: }
结果: 你对vim的魔法部分有什么建议? 拆分 Source: vim magic here, probably something visual selection based Result: What do you suggest for the vim magic part? Split the line on 这篇关于如何使vim按字母顺序在一行内排序CSS规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
.foo {clear:both; font-size:24px; line-height:150px; }
:s / \([{;] \)\s * / \1\r / g | '[+1,'] sort | '[,'] join
{
或;
将每个规则分成单独的行,:sort
CSS定义),然后将它们连接在一起。.foo { line-height: 150px; font-size: 24px; clear: both; }
.foo { clear: both; font-size: 24px; line-height: 150px; }
:s/\([{;]\)\s*/\1\r/g | '[+1,']sort | '[,']join
{
or ;
to get each rule into a separate line, :sort
them (omitting the first line containing the CSS definition), then join them back together.