Semi-OT: Very Weird Vi Behaviour

Home » CentOS » Semi-OT: Very Weird Vi Behaviour
CentOS 7 Comments

This is weird. As in, *deeply* weird.

I SSH as root from one box to another (there are keys involved), and I go to vi a file, such as
# line 1 #
# line 2 #
# line 3
# line 4

And what I see in vi is
# line 3
# line 4

BUT, if I scroll the cursor over each line with the arrow key… I see all four lines. I’ve also looked at another file, and same thing. Just checked it out on the server I ssh’d in from, and no problem. And now, I just ssh’d in from another windows, same way… and the weirdness isn’t there.

Anyone have any clues as to what’s going on with that one session?

mark

file

7 thoughts on - Semi-OT: Very Weird Vi Behaviour

  • It sounds as if, for some reason, in that one session, vi doesn’t know what your terminal settings are, so it’s in line editing mode (like ed or ex). I don’t have an explanation as to why it would only happen with that one session, though.

  • Or your “colors” could be set oddly in that terminal window/vi session.

    Unfortunately you are giving almost no details – OSs (original and target machine), shells, terminal settings, etc., so it’s hard to do more than jump to potentially rash conclusions.

  • Richard wrote:

    Sorry, original machine that I sudo’d to root is CentOS 6; the machine where it was acting weird was CentOS7. Terminal is rxvt, and my colors are set everywhere to be the color Ghod (and IBM) meant them to be, green on black.

    I’d been googling, and tried reset, and tried , and none of it helped. I renamed /root/.viminfo, and tried vi -V, which showed it only going after /etc/virc and /etc/vimrc, and neither modified. I also tried vi –noplugin.

    mark

  • m.roth@5-cent.us wrote:
    many years ago used to say, “professionally paid to be paranoid” – I log out of *everything*, including my workstation, when I leave for the night, so new session every day.

    mark

  • Mark, I can not reproduce it. I SSH (with the key) from FrraBSD 9.3 box
    (from either /bin/sh Bourne shell or /usr/local/bin/bash Bourne again shell) to CentOS 5 (fully updated, bash shell), and my vi does behave as expected, it is:

    which vi
    /bin/vi

    vi -V

    ~
    ~ VIM – Vi IMproved
    ~
    ~ version 7.0.237
    ~ by Bram Moolenaar et al.
    ~ Vim is open source and freely distributable

    I guess we need more detail about what you have.

    Here is the file I open with vi:

    cosmo ~]# cat test
    # line 1 #
    # line 2 #
    # line 3
    # line 4

    Here is what I see when I open it with vi:

    cosmo ~]# vi test

    # line 1 #
    # line 2 #
    # line 3
    # line 4
    ~

    Valeri

    ++++++++++++++++++++++++++++++++++++++++
    Valeri Galtsev Sr System Administrator Department of Astronomy and Astrophysics Kavli Institute for Cosmological Physics University of Chicago Phone: 773-702-4247
    ++++++++++++++++++++++++++++++++++++++++

  • A bit of a flyer, but I have issues w/ vi when I SSH to other machines on my LAN from an RXVT window. I am all *BSD, which is what makes this a flyer, but I do have issues w/ the vi/ssh/rxvt combo, to the point where I use xterm’s for windows where I know I will want to ‘vi’ something on another box (I *love* rxvt otherwise). $0.02, no more, no less ….

    William A. Mahaffey III

    ———————————————————————-

    “The M1 Garand is without doubt the finest implement of war
    ever devised by man.”
    — Gen. George S. Patton Jr.

  • That sounds like a file generated from different OS’s that have different end of line terminators. For example a line like this:

    # line 1 #\r# line 3\n (\r == CR, \n == NL)

    might display as just “# line 3” because the cursor returned to the beginning of the line at the “\r”.

    Jon