Tip 100: Alphabetize the Properties of Each Rule in a CSS File
Return to the top: <<Practical Vim>>
Example:
sort the properties of each rule into alphabetical order in a CSS file using :sort command.
References:
# If you open the file in vim, # then you can \"ayy@a the next line to execute the vim command: :h :sort
Sort Properties for a Single Block of Rules
vi{
:'<,'>sort
Sort Properties for Every Block of Rules
:g/{/ .+1,/}/-1 sort
NOTE: . here stands for each line in turn that matches the specified {pattern}.
Discussion
:g/{start}/ .,{finish} [cmd]
Example: indent the properties of each rule in a CSS file.
:g/{/ .+1,/}/-1 >
- 
:>Ex command 
References:
# If you open the file in vim, # then you can \"ayy@a the next line to execute the vim command: :h :>
- 
mute these messages by prefixing our 
[cmd]with:silent::g/{/sil .+1,/}/-1 > 
References:
# If you open the file in vim, # then you can \"ayy@a the next line to execute the vim command: :h :sil