开发者

Vim, css clean key map convert to function

开发者 https://www.devze.com 2023-01-28 07:49 出处:网络
I got this map for formating css into a one liner. map <silent> <leader>cssclean :%s@\\v/\\*([^*]\\|[\\r\\n]\\|(\\*+([^*/]\\|[\\r\\n])))*\\*+/@@g<Bar>:call CssPretty()<Bar> :%

I got this map for formating css into a one liner.

map <silent> <leader>cssclean :%s@\v/\*([^*]\|[\r\n]\|(\*+([^*/]\|[\r\n])))*\*+/@@g<Bar>:call CssPretty()<Bar> :%le<Bar>:%s/{\_.\{-}}/\=substitute(submatch(0), '\n', '', 'g')/<Bar>:nohl<cr>Gdd

This 开发者_StackOverflow社区map requires CssPretty.

Now I want to call this like :call CssClean() . I tried putting this one by reading this vim tip, but it didn't work.


What was the code of that function?

function CssClean()
    %s@\v/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/@@g
    call CssPretty()
    %le
    %s/{\_.\{-}}/\=substitute(submatch(0), '\n', '', 'g')/
    nohl
    normal! Gdd
endfunction

should work fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消