• [vim]一键编译运行c程序


    主要用来编译C语言的小程序,多文件IDE比较方便点。 我的vimrc

    有error时弹出quickfix窗口

    有warning时,运行编译结果,且弹出quickfix窗口

    没有任何提示时,直接运行

    
    function! CompileFile()
        if &filetype == 'c' || &filetype == 'cpp'
            if &filetype == 'c' | set makeprg=gcc -std=c99 -Wall -Wconversion -o %<.exe %
            else                | set makeprg=g++ -o %<.exe %
            endif
            silent exe "make"
            if getqflist() == []    "compile correct and no warning
                let l:flag = 0 | silent exe "ccl" | exe "!%<.exe"
            else
                for l:inx in getqflist()
                    for l:val in values(l:inx)
                        if l:val =~ 'error' | let l:flag = 1 | break
                        elseif l:val =~ 'warning' | let l:flag = 2
                        else | let l:flag = 0
                        endif
                    endfor
                    if l:val =~ 'error' | break | endif
                endfor
            endif
            if l:flag == 1| exe "cw"
            elseif l:flag == 2
                let l:select = input('There are warnings! [r]un or [s]olve? ')
                if l:select ==  'r' | exe "!%<.exe" | exe "cw"
                elseif l:select == 's' | exe "cw"
                else | echohl ErrorMsg | echo "input error!"
                endif
            else | exe "cw"
            endif
        elseif &filetype == 'python'
            exe "!%<.py"
        else
            echohl ErrorMsg | echo "This filetype can't be compiled !"
        endif
        echohl None
    endfunction
    

    Good Good Study! Day Day Up!

  • 相关阅读:
    晕晕的一天
    23. 合并K个排序链表
    25. K 个一组翻转链表
    328. 奇偶链表
    86. 分隔链表
    290. 单词规律
    202. 快乐数
    242. 有效的字母异位词
    16.最接近的三数之和
    (转) java 简单工厂模式(实现一个计算器)
  • 原文地址:https://www.cnblogs.com/kdurant/p/4150884.html
Copyright © 2020-2023  润新知