作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我得到一个CSS文件:
div#header h1 {
z-index: 101;
color: #000;
position: relative;
line-height: 24px;
margin-right: 48px;
border-bottom: 1px solid #dedede;
font-size: 18px;
}
div#header h2 {
z-index: 101;
color: #000;
position: relative;
line-height: 24px;
margin-right: 48px;
border-bottom: 1px solid #dedede;
font-size: 18px;
}
div#header h1 {
border-bottom: 1px solid #dedede;
color: #000;
font-size: 18px;
line-height: 24px;
margin-right: 48px;
position: relative;
z-index: 101;
}
div#header h2 {
border-bottom: 1px solid #dedede;
color: #000;
font-size: 18px;
line-height: 24px;
margin-right: 48px;
position: relative;
z-index: 101;
}
nmap <F7> /{/+1<CR>vi{:sort<CR>
最佳答案
:g#\({\n\)\@<=#.,/}/sort
g " Work over the whole file running .,/}/sort on each line that matches
" the pattern \({\n\)\@<=
#...#... " Delimiters: first bit is search pattern, second bit is what
" to do on each matching line
\( " Grouping, containing:
{\n " Open brace followed by new line
\) " End of grouping
\@<= " Negative look-behind, so match after the new-line, but make sure that
" the match point is preceded by an open brace and a new-line
.,/}/ " From this line to the next closing brace...
sort " Sort the lines
:nmap <F7> :g#\({\n\)\@<=#.,/}/sort<CR>
" Or:
:command! SortCSSBraceContents :g#\({\n\)\@<=#.,/}/sort
:SortCSSBraceContents
关于vim - 如何在Vim中按字母顺序排列CSS文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3050797/
我是一名优秀的程序员,十分优秀!