When I type vi
into a terminal it shows the following display:
Note that it says vim not vi, I'm sure I haven't downloaded vim yet and that this is actually vi not vim: for example the arrow keys print ABCD instead of moving.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityWhile the original vi
is still available, I do not think it is much used on current linux or BSD distributions;1 apparently it was dusted off in 2000 after having been mothballed a decade before that, and the last release was 2005.
There are various implementations of vi around, which is really now a POSIX specification. These include nvi
and elvis
, but the most popular is probably vim
.
On systems that use vim, vi
will simply be a softlink to it and when invoked this way it should start in vi-compatible mode, so the system has something that conforms to the POSIX spec. However, that doesn't change the actual name of the program, which is vim, and that's what you see on the title screen.
1. Although it is available on Arch, at least. You might find it other places too.
Vi
is part of the "base" group, which most people will select, but the Arch install process does not force you to install it.
If you are using Debian then vi
is opening as vim
because of the entry of vi
in /etc/alternatives
. Let me break this up for you.
When you do ls -l /usr/bin/vi
:
lrwxrwxrwx 1 root root 20 Jul 1 2014 /usr/bin/vi -> /etc/alternatives/vi
As you can see the vi
binary is a symbolic link to /etc/alternatives/vi
.
Now if you do ls -l /etc/alternatives/vi
:
lrwxrwxrwx 1 root root 18 Jul 1 2014 /etc/alternatives/vi -> /usr/bin/vim.basic
It's a symbolic link to the binary of vim.basic
.
So, in a nutshell: /usr/bin/vi
→ /etc/alternatives/vi
→ /usr/bin/vim.basic
As a result if you type vi
in the shell, vim.basic
will open.
You can check and change the values in the /etc/alternatives
by the command update-alternatives
but I think your original question is already answered.
On many Linux systems, the default vi
really is a version of Vim, typically one compiled with fewer options (no built-in perl and python support, no GUI, etc) than the one you would get if you installed a Vim package.
for example the arrow keys print ABCD instead of moving.
This is caused by an inconsistency between your terminal emulator and Vim's understanding of the terminfo/termcap entry being used. Generally, it is caused by Vim having sent the t_ks
code to "enable" the arrow keys (actually puts them in a mode where they send <1b>OA
instead of <1b>[A
) but the expected keys are for the other mode (e.g. t_ku=<1b>[A
for up arrow). Try changing your TERM environment variable or vim option (set term=builtin_ansi
or builtin_xterm
in vimrc might work, though it may disable color), using a different terminal, or as a last resort adding set t_ks= t_ke=
to your .vimrc
file to disable this mode switching. This is a suggested solution in vim's help files, the next paragraph after :help cs7-problem
.
This behavior is not in any way a sign that it is "actually vi not vim" - most modern "genuine" versions of vi or nvi also support the arrow keys.
The original question has already been answered explaining that vi is an alias for vim, and that it is normal for the command vi to start vim.
What should be noted is that vim is (in some setups) sensitive to which name it is called by. Even though vi
and vim
both execute the same binary they can behave differently.
Note in several Debian based distros the symbolic link in /bin/vi is to 'busybox' and not vim at all. In some cases this can be OK but the features busybox provides are a minimum set and for some reason seem to vary on how busybox was compiled.
If vim is installed it usually replaces the busybox link -- but sometimes not so -- busybox may still be linked to /bin/vi while vim is linked to /usr/bin/vi -- so it will depends on the PATH environment variable on which is found first. A typical user may get 'vim' but when logged in as 'root' get busybox vi.
Best to check and see which vi link you are using (which vi) and what that is linked to.
Anyway, vim
is a superset of vi
. Meaning, everything that works in vi
works in vim
. For all intents and purposes, it is a more extensible version of vi
.
for example the arrow keys print ABCD instead of moving.
There are 2 solutions to this.
vi
.set nocompatible
somewhere in your ~/.vimrc
(You can make the file if you don't have it). then restart your termninal.The second solution has always worked best for me.
vi
and vim
vi
fan, but according to this, character encoding and set nocompatible
have nothing to do with what the vi
command resolves to... Besides, setting nocompatible
is said to "stop vim
from behaving in a strongly vi-compatible way", which, in a way, is the opposite of what the OP seems to be looking for.
Feb 3, 2015 at 22:43
vi
linking to vim
, so I was addressing different solutions to the 'ABCD' spam. Which is why I immediately preceded the list with the quote stating his ABCD issue. Like I said, this should have been a comment on the original question instead of an answer, but this account currently lacks the reputation to post comments on any thread other than my own.
update-alternatives --display vi
readlink -e $(which vi)
for non-debian distros