如何使vim格式化这个LESS代码正确? =G
命令给出了可怕的结果。
以下是一个示例:
// главный слайдер main slider
.herounit-row {
position: relative;
}
.hero-box {
position:absolute;
top:0;
width:100%;
.centered();
}
以下是gg=G
:
// главный слайдер main slider
.herounit-row {
position: relative;
}
.hero-box {
position:absolute;
top:0;
width:100%;
.centered();
}
答案 0 :(得分:4)
如果您想使用Vim提供的文件类型,您可以:
:set ft=scss
之后gg=G
应该会提供预期的结果。
编辑:如果它适用于您的所有用例,您也可以自动执行此操作(我假设文件扩展名较少):
autoread BufNewFile,BufRead *.less set filetype=scss
答案 1 :(得分:1)
对我来说,这https://github.com/groenewege/vim-less效果很好。
但说实话,我只看到你的padding
行错了,剩下的就好了。
这是我在vim上编写的代码较少的代码:
h1,h2,h3,h4,h5,h6 {
font-family: @main-font;
}
.browse-button {
.transition(0.4s all);
line-height: 2.3em;
padding: 0 13px 0 13px;
background: @additional-color;
font-size: 1em;
border:none;
color:#fff;
white-space: nowrap;
.border-radius(15px);
&:hover {
color:#dfdfdf;
background:lighten(@additional-color, 10%);
}
&:active {
box-shadow:inset 0px 1px 3px rgba(0, 0, 0, .5);
}
}