6

How can use the t-vim module inside a TABLE environment?

I know it propably has something to do with buffers but I'm not sure how to store the output from vim into a buffer.

MWE:

\usemodule[vim]

\definevimtyping
  [somecode]
  [lines=split]

\starttext
\typebuffer[visit]

\bTABLE
    \bTR
        \bTD 
\startsomecode
test code
\stopsomecode
        \eTD
    \eTR
\eTABLE
\stoptext
  • 1
    I realized that process<vim>buffer was not documented, so I added it to the documentation at github – Aditya Nov 27 '18 at 16:44
6

Since t-vim is built on top of t-filter, you can can use the \process<filter>buffer command to load an existing buffer:

\usemodule[vim]

\definevimtyping
  [somecode]
  [lines=split]

\definevimtyping
  [RUBY]
  [syntax=ruby]

\starttext

\startbuffer[ruby]
# Ruby program listing
print("Hello World")
\stopbuffer

\startbuffer[somecode]
test code
more lines
\stopbuffer

\bTABLE
    \bTR
        \bTD
          \processsomecodebuffer[somecode]
        \eTD
        \bTD
          \processRUBYbuffer[ruby]
        \eTD
    \eTR
\eTABLE

\stoptext

You could alternatively use the module ntb-to-xtb, which lets you use xtables with natural table syntax (in other words: this lets you use TeXnicians solution without changing the code):

\usemodule[vim]
\usemodule[ntb-to-xtb]

\definevimtyping
  [somecode]
  [lines=split]

\definevimtyping
  [RUBY]
  [syntax=ruby]

\starttext

\bTABLE
    \bTR
        \bTD
\startsomecode
test code
more lines
\stopsomecode
        \eTD
        \bTD
\startRUBY
# Ruby program listing
print("Hello World")
\stopRUBY
        \eTD
    \eTR
\eTABLE

\stoptext

The output for both solutions is the same:

enter image description here

5

More of a comment than an answer: With xtables you may use verbatim material directly.

\usemodule[vim]

\definevimtyping
  [somecode]
  [lines=split]

\starttext
\typebuffer[visit]

\startxtable
    \startxrow
        \startxcell 
\startsomecode
test code
\stopsomecode
        \stopxcell
    \stopxrow
\stopxtable
\stoptext

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.