Folks,
After almost two years, I may have stumbled onto the root cause of this vi display corruption problem.
It looks to be related to the character encoding difference between the Linux system that uses UTF-8, and macOS (XQuartz) (X11) which apparently uses something else.
I solved this problem by starting my xterm sessions on macOS with this xterm command option:
-en UTF-8
and removed all other work-arounds on macOS and the Linux systems.
Now the vi edit display on macOS is no longer corrupted.
The key seems to be the the encoding difference seen on macOS as:
Riegner-iMac3:HPE dick$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
And that on one of our typical Linux systems:
linux-pu89:/dickie/text/$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
The root cause seems to be the extended non-ASCII characters in the text file. This solution does not handle all the extended non-ASCII characters exactly the same on macOS and Linux.
For example, on my local Linux xterm, the Linux vi shows the correct text for the local file:
491 If it's not logged in, then login as:
But on my macOS xterm, looking remotely at the same file on Linux, the Linux vi shows that the quote is missing; so vi displaying from Linux back to macOS is close, but not exact:
491 If it s not logged in, then login as:
I copied the Linux file locally to macOS and used the macOS version of vi to display the non-ASCII characters as hex using "set display=uhex":
491 If it <80><99>s not logged in, then login as:
So there are definitely extended non-ASCII characters in this text file contributing to the macOS, Linux, and vi confusion.
Another option is to set the macOS locale environment variables, but I do not know what side-effects and problems that may cause. So I am going with this macOS (XQuartz) (X11) solution:
xterm -en UTF-8
None of the vi display corruption is seen using the macOS Terminal application. This sure looks to be a macOS (XQuartz) (X11) issue, but vi is front-and-center when the display corruption is seen.
I hope this solution turns out to be solid and helps other vi users running XQuartz on macOS.
--
Dick Riegner
dic...@nuveramail.net
--