How to redirect stdout output to a new Vim tab?

前端 未结 3 860
灰色年华
灰色年华 2021-02-07 03:07

I\'m editing an XML file in Vim, and then I want to transform it a plain-text file with xsltproc, which by default outputs to a stdout (something like : !xsltproc TXTRULE.XSL %)

3条回答
  •  醉酒成梦
    2021-02-07 03:40

    I am using the following to view my program outputs (very useful for a makefile with a make run rule)

    It opens a new tab next to current one only if one was not already opened before for that purpose:

    fu! RedirStdoutNewTabSingle(cmd)
      let a:newt= expand('%:p') . ".out.tmp"
      tabnext
      if expand('%:p') != a:newt
        tabprevious
        exec "tabnew" . a:newt
      else
        exec "%d"
      endif
      exec 'silent r !' . a:cmd
      set nomodified
    endfunc
    
    au FileType xml noremap   :call RedirStdoutNewTabSingle("xsltproc")
    

提交回复
热议问题