代码之家  ›  专栏  ›  技术社区  ›  Martín Fixman

在Vim中:compiler命令做什么?

  •  24
  • Martín Fixman  · 技术社区  · 15 年前

    我在手册页上搜索了一下,但没有找到任何关于它实际功能的有用信息,Vim Wiki也没有。有人知道那个命令实际上是做什么的吗?

    4 回复  |  直到 15 年前
        1
  •  18
  •   John Kugelman Michael Hodel    15 年前

    :make $VIMRUNTIME/compiler/ 为不同的.vim文件,可以来源。

    :help write-compiler-plugin

    编译器插件设置用于特定编译器的选项。用户可以 :compiler 命令。主要用途是设置 “errorformat”和“makeprg”选项。

    另请参见 :help errorformat :help makeprg .

    下面是我机器上的GCC编译器文件,例如:

    /usr/share/vim/vim72/compiler/gcc.vim

    " Vim compiler file
    " Compiler:         GNU C Compiler
    " Maintainer:       Nikolai Weibull <now@bitwi.se>
    " Latest Revision:  2006-12-20
    
    if exists("current_compiler")
      finish
    endif
    let current_compiler = "gcc"
    
    let s:cpo_save = &cpo
    set cpo-=C
    
    CompilerSet errorformat=
          \%*[^\"]\"%f\"%*\\D%l:\ %m,
          \\"%f\"%*\\D%l:\ %m,
          \%-G%f:%l:\ %trror:\ (Each\ undeclared\ identifier\ is\ reported\ only\ once,
          \%-G%f:%l:\ %trror:\ for\ each\ function\ it\ appears\ in.),
          \%f:%l:\ %m,
          \\"%f\"\\,\ line\ %l%*\\D%c%*[^\ ]\ %m,
          \%D%*\\a[%*\\d]:\ Entering\ directory\ `%f',
          \%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',
          \%D%*\\a:\ Entering\ directory\ `%f',
          \%X%*\\a:\ Leaving\ directory\ `%f',
          \%DMaking\ %*\\a\ in\ %f
    
    if exists('g:compiler_gcc_ignore_unmatched_lines')
      CompilerSet errorformat+=%-G%.%#
    endif
    
    let &cpo = s:cpo_save
    unlet s:cpo_save
    
        2
  •  10
  •   Pierz    6 年前

    Makefile 生存。

    here ):

    :make %:r
    

    快速修复 ( :help quickfix )列表- :cn 下一个错误, :cp 上一个错误, :cw

    :se makeprg=gcc\ -o\ %<\ %
    

    或者把它放在~/.vimrc文件中:

    set makeprg=gcc\ -o\ %<\ %
    

    :make
    

    它将编译文件并提供 快速修复

    编辑:如果您还想从vim中运行编译的可执行文件,您可以执行('!'执行,“%:r”是不带后缀的文件名):

     :!./%:r
    
        3
  •  1
  •   Nick Bastin    15 年前
    :help compiler
    

    它为当前缓冲区的选定编译器设置选项。

        4
  •  0
  •   max    15 年前