1

What is the best way to deal with remnant text in vim editor? I'm ssh to a remote terminal using Xquartz, and edit my code using vim. When I hit return, there remains text displayed in the current line, even thought they are actually moved to the next line. It becomes hard to read and I have to restart vim every now and then. Is there a solution for that problem?

For example: if I add set cursorline in my .vimrc and then move the cursor around it will show like this, and :redraw! won't fix the problem: Screenshot of my xterm

1
  • 2
    you have got to do ^L, redraw Commented Feb 19, 2018 at 20:41

1 Answer 1

2

You have to have the correct terminal type in your TERM variable, and inform the remote host of your terminal size with stty rows <rows> columns <cols>.

Nowadays, I only have to do this when dealing with embedded hosts over serial consoles; the SSH protocol knows how to communicate these settings from the local system to a remote Unix-like kernel (or to generate the settings in the case of a client like PuTTY).

Maybe you have some shell .profile script on the remote host which is putting an inappropriate value into TERM or messing up the TTY info with bogus stty commands.

[UPDATE]

The example display now shown in the question looks very much like horizontal scrolling. Just type 0 to jump to the leftmost column.

You can disable horizontal scrolling using :set wrap; then long lines are wrapped. To enable horizontal scrolling again, use :set nowrap.

3
  • Thanks for the input, I am new to vim or Linux in general. Can you show me in more detail how to set it up? And I just ls -a in my $HOME, and there is no .profile
    – Danyang Su
    Commented Feb 19, 2018 at 21:06
  • .profile is both a literal filename and often used as a handy short-hand for "shell startup scripts". bash, for example, uses /etc/profile, ~/.profile, and ~/.bash_profile on login shells and ~/.bashrc for non-login shells. And some others which i can't remember right now (insufficient coffee error), see the man page for your shell for details.
    – cas
    Commented Feb 20, 2018 at 1:13
  • a followup question: If I do want to keep the horizontal line, but Also keep the display updated whenever I move my cursor, what should I do. I did find a temporary solution: when I enter vim, I type :!clear then hit enter, then everything works fine for the vim session. I don't know how does it work, or how to achieve it without manually doing it everytime I vim
    – Danyang Su
    Commented Feb 20, 2018 at 19:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .