0

So I ssh into this old box we have at work, and it seems no one ever tried to use Vi on it before. When I try to open a file in vi all I get is one line of the file at a time, and it kind of screws up (visually) the terminal.

full terminal

relevant terminal

I am sshing in from a Mac, if that makes a different (however other servers I ssh into for work are fine).

When I run uname -a I get: Linux dev 2.6.32.27-grsec #5 SMP Thu Dec 30 01:24:01 PST 2010 i686 unknown unknown GNU/Linux. I am using bash but if something else will work I am all ears.

This has to have happend to someone else, what setting am I missing that is causing this issue?

Thanks!

UPDATE: After research from comments, I found that this is only an issue with vi, not vim. So that begs the question, is this just an incompatibility with vi (not vim) and current ssh/terminal/shells, or is something else going on?

SOLVED: This was a carriage return -> new line issue that the old vi didn't handle properly. Running stty with an argument to convert carriage returns to new lines allowed vi to work properly. Hopefully that helps someone that can't upgrade to vim.

xbakesx
  • 13,202
  • 6
  • 48
  • 76
  • 2
    What is the result of running `which vi` or `type vi`? – Explosion Pills Jun 01 '13 at 20:04
  • It sounds like your TERM variable is set wrong. – FDinoff Jun 01 '13 at 20:27
  • Do `vi --version` while you're at it. This looks like something ancient. – glts Jun 01 '13 at 20:32
  • Interesting, typing apparently vi and vim are both installed. vim seems to work, but vi doesn't. The output of `vi --version` is `elvis 2.2.0`. and `echo $TERM` gives me `xterm-256color`. Not that it's entirely relevant but `vim --version` is `VIM - Vi IMproved 6.3` – xbakesx Jun 01 '13 at 20:37
  • So is this just an incompatibility with vi (not vim) and current ssh/terminal/shells, or is something else going on? It's not important I guess because I'll just be using vim, but for posterity...? – xbakesx Jun 01 '13 at 20:53
  • I seem to remember that that's how vi used to work very long time ago. –  Jun 01 '13 at 21:05
  • Run `stty -a` at the command prompt; see what size that thinks the terminal is. Since `vim` gets it right, it might be accurate and `vi` is getting it wrong. Is your `vi` a separate executable from `vim`? On my Mac, `/usr/bin/vi` is a symlink to `/usr/bin/vim`, but they might be different executables on your machine. – Jonathan Leffler Jun 02 '13 at 06:33
  • Had a similar situation when I fat-fingered a command. Probably `z1` or something. I was able to fix it with `z1000`. – Iiridayn Jan 24 '23 at 18:44

2 Answers2

2

Elvis (or vi) is probably being controlled by the properties of the terminal. My guess is vi would start working if you stty onlcr. See How to toggle CR/LF in gnu screen?

Community
  • 1
  • 1
cforbish
  • 8,567
  • 3
  • 28
  • 32
  • Thanks @cforbish. My version of stty didn't have `onclr` as an argument, but it did have `icrnl` that translated carriage returns to newlines and that was definitely the problem. Hopefully this helps some poor unfortunate soul that can't upgrade his version of vi. – xbakesx Jun 04 '13 at 02:53
  • 1
    As an addendum to this answer, while running on QNX neither onclr or icrnl existed for me. The solution to my problem was to change the $TERM to qansi from xterm-256. Hopefully this helps someone down the line. – Fields Mar 24 '17 at 17:40
1

Elvis is an old vi clone (2.2.0 was released in 2003) that used to be shipped with some distributions in order to provide the vi command required by the UNIX standard.

I have never used it and I think that few of those who have direct experience with Elvis still use it so your chances of getting an authoritative answer here are pretty slim.

One thing you could do is read $ man elvis or maybe $ elvis --help and see if Elvis is launched with some specific argument destined to make it vi-compatible. Or see if it can be launched with specif arguments that make it more workable.

Anyway, neither vi nor elvis (both old and either completely dead or not actively maintained) can hold a candle to Vim. If you intend on doing any serious work on this machine I'd suggest you install a recent Vim (latest stable version is 7.3) and forget all about Elvis.

romainl
  • 186,200
  • 21
  • 280
  • 313