Skip to content

Instantly share code, notes, and snippets.

@yuya-matsushima
Last active December 12, 2015 07:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuya-matsushima/4735680 to your computer and use it in GitHub Desktop.
Save yuya-matsushima/4735680 to your computer and use it in GitHub Desktop.
sass書く時に":"の後にスペースがないとエラーするみたいなので、保存時に矯正するようにした
function! SassCorrect()
let s:cursor = getpos(".")
%s/\(\S\+\):\s\+\(.\+$\)/\1:\2/e
%s/\([^\s\t:]\+\):\(\/\/\|link\|visited\|active\|hover\|focus\|lang\|before\|after\|first\-line\|first\-letter\|first\-child\|last\-child\|target\|enabled\|disabled\|checked\|indeterminate\|root\|nth\-child\(.\+\)\|nth\-last\-child\(.\+\)\|nth\-of\-type\(.\+\)\|nth\-last\-of\-type\(.\+\)\|first\-of\-type\|last-of\-type\|only\-child\|empty\|-moz-any-link\|default\|root\|contains\(\)\|not\(\)\)\@!/\1: \2/e
call setpos(".", s:cursor)
endfunction
au BufWritePre *.scss,*.sass call SassCorrect()
@charset "utf-8"
/* Sass Test File for SassCorrect.vim
*
* SassCorrect.vim の動作確認用テストSassファイル
* 保存処理を行った際に正しいsyntaxが得られれば問題ない(はず
*/
@import url(http://www.e2esound.com/font-data)
@import url(https://www.e2esound.com/font-data)
@import url(//www.e2esound.com/font-data)
#test
.url
background:url(http://www.e2esound.com/test_image.jpg)
background: url(http://www.e2esound.com/test_image.jpg)
a
&:link
color:blue
color: blue
&:visited
color:orange
color: orange
&:hover
text-decoration: underline
text-decoration:underline
&:focus
color:red
color: red
span
&:before
content:"$"
content: "^"
&:after
content:"$"
content: "$"
div:first-line
text-decoration:underline
text-decoration: underline
p:first-letter
font-size:2em
font-size: 2em
ul
li
&:first-child
color:red
color: red
&:last-child
color:green
color: green
p:target
background:red
background: red
input
&:enabled
border-color:black
border-color: black
&:disabled
border-color:white
border-color: white
&:checked
border-color:red
border-color: red
font:
family:hiragino
family: hiragino
weight:bold
weight: bold
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment