vimrc - How does vim map keys based on the file extension?
某草草2017-05-16 16:36:29
0
1
550
For example, when editing the.cppfile, you want to mapto:call CompileCpp(). When compiling the.htmlfile, I want to mapto:call RunHtml(). Can this be done?
But it is recommended to set makeprg when using autocmd FileType, and then just make directly when using F5. This will display the error message to quickfix This is the other language I set
augroup make_autocmd autocmd Filetype javascript setlocal makeprg=jsl\ -nologo\ -nofilelisting\ -nosummary\ -nocontext\ -conf\ /etc/jsl.conf\ -process\ % autocmd FileType json setlocal makeprg= autocmd FileType php \ setlocal makeprg=php\ -l\ -n\ -d\ html_errors=off\ % | \ setlocal errorformat=%m\ in\ %f\ on\ line\ %l autocmd BufWritePost * call Make() " auto close quickfix if it is the last window autocmd WinEnter * if winnr('$') == 1 && getbufvar(winbufnr(winnr()), "&buftype") == "quickfix" | quit | endif augroup END function! Make() if &modified | silent write | endif if &makeprg == 'make' | return | endif let regname = '"~' let old_pos = getpos('.') silent make execute 'cw' if !has('gui_running') | redraw! | end call setpos('.', old_pos) endfunction
Probably use this
But it is recommended to set makeprg when using autocmd FileType, and then just make directly when using F5. This will display the error message to quickfix
This is the other language I set