国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

vimrc - How to configure vim to automatically execute a certain command line command when executing the :w save command?
我想大聲告訴你
我想大聲告訴你 2017-05-16 16:36:31
0
3
1093

I am writing a a.less file. I want to automatically call the lessc command to compile the file into when executing the :w save command. a.css file. The format of the lessc command is lessc a.less a.css.
How to set it up?


I don’t know why autocmd BufWritePost doesn’t work, so I have to use autocmd BufWriteCmd.

function! CompileLess()
    exec "w"
    exec "!lessc % > %:t:r.css"
endfunction

if executable("lessc")
    autocmd BufWriteCmd *.less call CompileLess()
endif
我想大聲告訴你
我想大聲告訴你

reply all(3)
小葫蘆

The code is roughly as follows. You can improve it yourself in cmd. You can use system to get out the compilation result. If there is an error, it will be output, so that you can easily locate the error

function! CompileLess()
    let cmd = 'lessc + ' +  expand('<afile>:p:h')
    let output = system(cmd)
    if v:shell_error
        echohl WarningMsg | echo output
    endif
endfunction
if executable('lessc')
    autocmd BufWritePost *.less call CompileLess()
endif
Ty80

I don’t know about vim, but you can use tools like gulp to monitor file updates

洪濤

Your idea of ??solving the problem is quite strange.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template