How to change default vi alias in Fedora 14?

2

In my laptop, if I type below

$ which vi
alias vi='vim'
    /usr/bin/vim

Now I want to change the vi alias to another bin, e.g. vim_wrapper a script created in /usr/bin/, I type this line:

alias vi="vim_wrapper"

in ~/.bashrc or /etc/bashrc, but take no effects. So How to change the default vi alias vi='vim' to vi='vim_wrapper'? Thanks for help!

Jason

Posted 2011-05-25T15:53:40.307

Reputation: 347

Answers

3

Aliases added to bashrc don't take effect immediately. You have to restart your terminal session or logout and log back in.

To make the alias take effect immediately, run the alias line you added on a terminal as if it were a command or source your bashrc as Nitrodist explains in the first comment.

Patches

Posted 2011-05-25T15:53:40.307

Reputation: 14 078

Not quite the same thing. You have to source the file (instead of running it with ~/bashrc on its own), otherwise the changes will not be reflected in the terminal. So, either do . ~/.bashrc or source ~/.bashrc. – Nitrodist – 2011-05-25T17:40:41.707

@Nitrodist: Out of curiosity, what is the difference? Obviously your method is better if you add more than one alias or make other changes, but for just adding one alias you'd think both methods would have the same effect. – Patches – 2011-05-25T17:48:40.133

just executing the file does not make those changes available in your terminal. If I export a variable in the .bashrc and I execute the script instead of sourcing it, then that exported variable disappears after the script finishes executing. See http://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-and-sourcing-a-bash-script http://stackoverflow.com/questions/1107808/what-happens-when-i-execute-a-unix-shell-script-using-a-command and http://stackoverflow.com/questions/1880735/difference-between-launching-a-script-with-script-sh-and-script-sh

– Nitrodist – 2011-05-25T18:21:53.123

@Nitrodist: I meant run the alias command, but that wasn't very clear in my post. I've updated it. – Patches – 2011-05-25T19:05:29.023

1

You can try to modify the original vi alias set. Here's my grep result:

/etc/profile.d/vim.sh: alias vi >/dev/null 2>&1 || alias vi=vim

Riller

Posted 2011-05-25T15:53:40.307

Reputation: 11