VIM利用KeilC工具编译源代码

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



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值