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

don't clear screen, on specific invocations?

Expand Messages
  • Aaron Davies
    is there a way to get vim to not clear the screen only on specific invocations? basically i want to use vim to print syntax-highlighted code on a color
    Message 1 of 2 , Jan 2, 2013
    • 0 Attachment
      is there a way to get vim to not clear the screen only on specific invocations?

      basically i want to use vim to print syntax-highlighted code on a
      color printer. "vim +ha +q foo.c" works nicely, but on some systems,
      it has the side-effect of clearing the screen and leaving the cursor
      at the bottom line, while on others, it makes a big annoying flash as
      the screen redraws, then restores.

      ideally i'd like something i could pass as an option that would
      completely turn off the redraw behaviors for that specific run.
      --
      Aaron Davies
      aaron.davies@...

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Gary Johnson
      ... This behavior uses the terminal s alternate screen. See ... for a brief discussion of this. Whether the alternate screen is used depends on the
      Message 2 of 2 , Jan 2, 2013
      • 0 Attachment
        On 2013-01-02, Aaron Davies wrote:
        > is there a way to get vim to not clear the screen only on specific
        > invocations?
        >
        > basically i want to use vim to print syntax-highlighted code on a
        > color printer. "vim +ha +q foo.c" works nicely, but on some systems,
        > it has the side-effect of clearing the screen and leaving the cursor
        > at the bottom line, while on others, it makes a big annoying flash as
        > the screen redraws, then restores.
        >
        > ideally i'd like something i could pass as an option that would
        > completely turn off the redraw behaviors for that specific run.

        This behavior uses the terminal's alternate screen. See

        :help :xterm-screens

        for a brief discussion of this. Whether the alternate screen is
        used depends on the capabilities of the terminal you are using, the
        capabilities advertised by the terminfo or termcap database, whether
        the feature is enabled or disabled in the terminal, and the setting
        of Vim's 't_te' and 't_ti' options.

        As an example of how this behavior can be controlled, I usually like
        to have Vim leave its display on the terminal screen when it exits,
        but not when I'm using it to edit a bash command line, so I have
        this in my ~/.vimrc:

        if argv(0) !~ '^/tmp/bash-fc-\d\+$'
        set t_ti= t_te= " Disable screen switching
        " unless Vim is being used to edit a
        " bash command line. In that case,
        " we don't want Vim to screw up the
        " screen.
        " Only the new color xterm and rxvt
        " seem to allow this. See ":help
        " xterm-screens". This can be
        " disabled within xterm itself via
        " the titeInhibit resource, but that
        " still leaves extra characters on
        " the screen when vim exits.
        " Setting these here also cleans up
        " those characters.
        else
        au BufWinEnter * if &ft == "" | set ft=sh | endif
        endif

        I also have a script at work (so I can't refer to it at the moment)
        that contains these lines:

        tput smcup
        vim "$@"
        tput rmcup

        where smcup and rmcup are the terminfo equivalents of t_ti and t_te,
        which also causes the screen to be restored after Vim exits. See
        the terminfo(5) man page.

        HTH,
        Gary

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      Your message has been successfully submitted and would be delivered to recipients shortly.