Loading ...
Sorry, an error occurred while loading the content.

Slightly OT: Vim/Cat

Expand Messages
  • A. S. Budden
    Hi there, This is possibly optimistic and almost certainly off-topic, but I was wondering if it is possible to make vim open a file and just dump it to
    Message 1 of 4 , Sep 30, 2003
    • 0 Attachment
      Hi there,

      This is possibly optimistic and almost certainly off-topic, but I was
      wondering if it is possible to make vim open a file and just dump it to
      standard out, with syntax highlighting/tab spacing etc done.

      My linux console certainly supports colours if I do "ls" or "ls
      --color=always | more" (this doesn't work with less), and I was
      wondering if I could have a version of cat that uses vim to syntax
      highlight and dump the output on the screen.

      Just wondering...

      Cheers,

      Al
    • Thomas Köhler
      ... Not exactly. ... You might want to try less -r :-) ... Purhaps something similar to the attached vimrc might help you. It won t work with stdout, so no
      Message 2 of 4 , Sep 30, 2003
      • 0 Attachment
        A. S. Budden wrote [2003/09/30]:
        > This is possibly optimistic and almost certainly off-topic, but I was
        > wondering if it is possible to make vim open a file and just dump it to
        > standard out, with syntax highlighting/tab spacing etc done.

        Not exactly.

        > My linux console certainly supports colours if I do "ls" or "ls
        > --color=always | more" (this doesn't work with less),

        You might want to try "less -r" :-)

        > and I was wondering if I could have a version of cat that uses
        > vim to syntax highlight and dump the output on the screen.
        >
        > Just wondering...

        Purhaps something similar to the attached vimrc might help you.
        It won't work with stdout, so no "vim | less -r". If you need a
        pager, you should use vim as a pager in the first place :-)

        Ciao,
        Thomas

        --
        Thomas Köhler Email: jean-luc@... | LCARS - Linux
        <>< WWW: http://jeanluc-picard.de | for Computers
        IRC: jeanluc | on All Real
        PGP public key available from Homepage! | Starships
      • Thomas Köhler
        ... Uhm, not exactly what it should be. It s better to first test and then send mail :) Try attached better version (which needs some keytyping to quit vim
        Message 3 of 4 , Sep 30, 2003
        • 0 Attachment
          Thomas Köhler wrote [2003/09/30]:
          > A. S. Budden wrote [2003/09/30]:
          > Purhaps something similar to the attached vimrc might help you.
          > It won't work with stdout, so no "vim | less -r". If you need a
          > pager, you should use vim as a pager in the first place :-)

          Uhm, not exactly what it should be. It's better to first test and
          then send mail :)
          Try attached better version (which needs some keytyping to quit
          vim because CursorHold gets only fired once).

          Ciao,
          Thomas

          --
          Thomas Köhler Email: jean-luc@... | LCARS - Linux
          <>< WWW: http://jeanluc-picard.de | for Computers
          IRC: jeanluc | on All Real
          PGP public key available from Homepage! | Starships
        • Antoine J. Mechelynck
          ... I don t know how to dump a syntax-colored file with interspersed terminal-control sequences, which seems to be what you want. But, starting at :help
          Message 4 of 4 , Sep 30, 2003
          • 0 Attachment
            A. S. Budden <vim.mail@...> wrote:
            > Hi there,
            >
            > This is possibly optimistic and almost certainly off-topic, but I was
            > wondering if it is possible to make vim open a file and just dump it
            > to standard out, with syntax highlighting/tab spacing etc done.
            >
            > My linux console certainly supports colours if I do "ls" or "ls
            > --color=always | more" (this doesn't work with less), and I was
            > wondering if I could have a version of cat that uses vim to syntax
            > highlight and dump the output on the screen.
            >
            > Just wondering...
            >
            > Cheers,
            >
            > Al

            I don't know how to dump a syntax-colored file with interspersed
            terminal-control sequences, which seems to be what you want. But, starting
            at ":help 2html.vim", there is a description (in some 80 lines of help text)
            of how to convert a syntax-colored file you see in Vim, to something that
            can be viewed with the same colors in a web browser such as (for instance)
            Netscape. To view the result, just use as your URL the full path name of the
            output file, prefixed with the word "file", a colon, and three slashes.

            OTOH, using the 'printoptions' option and the ":hardcopy" command, you can
            write your file to a printer (or to a file suitable to be sent to a
            printer), with or without syntax coloring.

            HTH,
            Tony.
          Your message has been successfully submitted and would be delivered to recipients shortly.