VIM利用KeilC工具编译源代码

xiaoxiao2021-02-28  75

map <F6> :call Complite()<CR><CR> function Complite()       if filereadable("Complier.cmd")        execute '!Complier.cmd'   else         let cscope_file=findfile("cscope.out", ".;")         let cscope_pre=matchstr(cscope_file, ".*/")         if !empty(cscope_file) && filereadable(cscope_file)         execute '!Complier.cmd'     endif          endif   " execute '!set C51INC =' . KeilPath . '\INC'   " execute '!set C51LIB =' . KeilPath . '\LIB' endfunction map <F7> :call Test() <CR> <CR> function Test() "execute '!dir ' . shellescape(expand('<cfile>'), 1) ":set suffixesadd=.c echo expand("#<:t") "findfile("main.c",".") ":echo "this is test" endfunction nmap fi :!start C:\Program Files\Mozilla Firefox\firefox.exe <CR> <CR> nmap stc :!start C:\Users\Administrator\Desktop\STC\stc-isp-15xx-v6.85O\stc-isp-15xx-v6.85O.exe <CR> <CR> set helplang=cn map <F9> :call Compiler() <CR> <CR> function Compiler()        :call ConvObj("C51.exe","\*.c")        :call LINK("BL51.exe","\*.OBJ")        :call Hex() endfunction    function ConvObj(cmd,file)     let l:CurDirFiles =substitute(globpath(".",a:file),'.\\','','g')     let b:StrLen = strlen(l:CurDirFiles)     let b:ii =0     "expend(l:CurDirFiles)     if l:CurDirFiles !="" && l:CurDirFiles !~ '\n$'     let l:CurDirFiles =l:CurDirFiles."\n"     endif     silent execute '!echo Compile Start--  >Compiler.txt'     if l:CurDirFiles !=""     while b:ii < b:StrLen          let l:Pos = match(l:CurDirFiles,'\n',0)         let l:SingleFile= substitute(strpart( l:CurDirFiles,0,l:Pos),'\s\+$','','')          if l:SingleFile != ''                let l:CurDirFiles =strpart(l:CurDirFiles,l:Pos+1)         "put='^^^^^^^^^^^^^'              "put=l:SingleFile          "put='++++++++++++'          "put=l:CurDirFiles          "put='----------'       " let swstr= "Compiler ".l:SingleFile." ".expand(l:SingleFile,"%:t:r")."obj"          silent execute '!echo '.l:SingleFile.'.... >> Compiler.txt'          silent execute '!'.a:cmd.' '.l:SingleFile.'>> Compiler.txt'        let  b:ii  +=l:Pos            let  b:ii  +=1        else             let l:CurDirFiles =strpart(l:CurDirFiles,1)                 let  b:ii  +=1        endif     endwhile    endif endfunction function LINK(cmd,file)     let l:CurDirFiles =substitute(globpath(".",a:file),'.\\','','g')     let l:CurDirFiles= substitute(l:CurDirFiles ,'\s\+$',' ','g')     let l:CurDirFiles= substitute(l:CurDirFiles ,'\n',',','g')     "put=l:CurDirFiles     silent execute '!'.a:cmd.' '.l:CurDirFiles.' TO target.out RAMSIZE^(256^)'.'>> Compiler.txt'      silent execute '!echo '.strftime('%c').' >> Compiler.txt'     :vi  Compiler.txt     :%s/.*COPYRIGHT KEIL ELEKTRONIK GmbH 1987 - 2009.*//g     :%s/.*C51 COMPILER V8.18 - SN: D1RMC-XVZPMC.*//g     :%s/^\n//g     :w endfunction function Hex()     silent execute '!OH51.exe target.out' endfunction map <F11> :call Mycsadd() <CR> <CR> function Mycsadd()     silent execute '!cscope -Rb '.expand("%:p:h").'/*'     silent execute 'normal cs add cscope.out' endfunction map <F10> :!ctags -R –c++-kinds=+p –fields=+iaS –extra=+q .<CR> set nobackup

set noswapfile

转载请注明原文地址: https://www.6miu.com/read-50701.html

最新回复(0)