[sf-lug] FWIW and :r! dig -t ns sf-lug.com
Rick Moen
rick at linuxmafia.com
Wed Oct 24 21:00:54 PDT 2007
Quoting Tomer (tomer at pacbell.net):
> I love vim by the way. I just hate how in ubunutu even though I go
>
> mv /usr/bin/vi /usr/bin/viNOUSE
> ln /usr/bin/vim /usr/bin/vi
Hmm, you really shouldn't. More about that below.
> And then go
> vi <something>
>
> I still get the old vi behaviour, instead of vim .. I must be missing
> something
Do you mean, when you're in the initial command mode, and you type "i",
you don't see "-- INSERT --" in the left-hand corner?
If you don't, try this vi command:
:set nocp
(Press Return.)
That's "set no compatibility mode". Compatibility mode is where vim
emulates nvi as closely as it can, including no "-- INSERT --" or
"-- REPLACE --" indicators.
If "set nocp <return>" and then "i" doesn't turn on the "-- INSERT --"
indicator, then it's not vim you're running, but rather probably
nvi.
Not that there's anything wrong with that.
<eyeing Asheesh, and backing away slowly>
If that _does_ enable the indicators, then it may be just a matter of
vim detecting the fact that it was running with binary name "vi" and
deciding that it should run in compatilbity mode. Which points out one
possible snag with your approach.
Anyhow, the *buntu family (Ubuntu, Kubuntu, Gubuntu, Edubuntu, Xubuntu,
Fluxbuntu, etc.) inherit from Debian a mechanism called "alternatives".
You'll note in /etc/alternatives a big long set of symbolic links --
and nothing but symbolic links. E.g., on the Debian box I'm sending
this from:
:r! ls -l /etc/alternatives/vi
lrwxrwxrwx 1 root root 12 2006-03-05 18:33 /etc/alternatives/vi -> /usr/bin/vim
So, "/etc/alternatives/vi" is a symbolic link pointing to /usr/bin/vim
-- at the moment. And, /usr/bin/vi is...
:r! ls -l /usr/bin/vi
lrwxrwxrwx 1 root root 20 2006-03-05 18:33 /usr/bin/vi -> /etc/alternatives/vi
...a symbolic link pointing to /etc/alternatives/vi . So, if I type
"vi" at the command prompt, that invokes
/usr/bin/vi -> /etc/alternatives/vi -> /usr/bin/vim
Debian (and thus also *buntu) provides a tool for determining _which_
vi /etc/alternatives/vi points to. It's called "update-alternatives",
should be run by the root user (using sudo, on *buntu), and has quite a
few options. On my Debian system:
# update-alternatives --list vi
/usr/bin/vim
In other words, I have only the one implementation of vi (vim)
installed, and not, e.g., the elvis or nvi implementations. But I could
have all three, and use "update-alternatives --config" to pick, at any
given time, which one becomes the default vi that is invoked if the user
merely says "vi".
But, also, if you're trying to specify which vi just _your_ login will
run by default, and are not trying to alter what other users will get,
then you shouldn't touch the system files at all, and instead should
use something like a bash alias in your ~/.bashrc file:
:r! grep alias .bashrc
# enable color support of ls and also add handy aliases
alias ls='ls --color=auto'
#alias dir='ls --color=auto --format=vertical'
#alias vdir='ls --color=auto --format=long'
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
So, you could add one saying
alias vi='/usr/bin/vim'
More information about the sf-lug
mailing list