vi copy/paste - maybe a bit OT

Bill Cole macportsusers-20171215 at
Thu Jul 4 20:22:24 UTC 2019

On 4 Jul 2019, at 14:55, Michael wrote:

> On 2019-07-04, at 3:03 AM, Richard L. Hamilton <rlhamil at> 
> wrote:
>> AFAIK, if your terminal display is restored after exiting vi, the 
>> terminal provides (and vi uses, via the smcup and rmcup terminfo 
>> strings) an alternate
>> buffer, for full-screen use.  Ideally, that alternate buffer should 
>> NOT include any scroll back, so I think the behavior you describe 
>> might even be a bug.
> This "Separate screen" behavior has always irked me. It means that as 
> soon as I leave a curses-based display -- such as anything going 
> through "less" as a pager -- such as man pages -- then I lose all the 
> information I was looking at a moment ago.

'export LESS=-FRX' is a line I put in ~/.bashrc or ~/.shrc on every 
machine I log in to. If you only want to eliminate the clear-on-exit, 
you can omit 'FR' or see 'man less' for all of the options. Obviously 
this is only for 'less' and not other programs like vi(m).

> The problem for me is always that switching to a termcap/terminfo 
> setting that doesn't have this problem results in other settings being 
> lost because it's too generic.
> Right now, I use "TERM=ansi", because I cannot stand that "We'll clear 
> your screen of the info you wanted now" behavior.
> What's the best term setting to use for maximum abilities without 
> losing that data,

That's a very good question. I suspect that there's some 
ansi/vt220/xterm variant that disables the alternate screen buffer but 
retains xterm-like functionality, but I'm not sure what it is.

There's a page at 
which offers advice on this and a "xterm-noalt" definition which may or 
may not do what you want. I have NOT tested anything there, it is just 
the 1st result from searching for 'xterm alternate screen'

> or is there some way to get that data back when you leave full-screen 
> mode? (is there a second output buffer that can be switched between 
> somehow?)

Yes. There's the "Show Alternate Screen/Hide Alternate Screen" commands 
in Terminal's View menu. Do those not do what you want?

Bill Cole
bill at or billcole at
(AKA @grumpybozo and many * addresses)

More information about the macports-users mailing list