Can’t run vi from terminal

bashterminalvi

Every time I execute these commands:

vi

or

vim

in the terminal, it gives me the following error:

-bash: /usr/local/bin/vi: No such file or directory

or

-bash: /usr/local/bin/vim: No such file or directory

How do I get it to look at /usr/bin instead of /usr/local/bin?

type -a vi vim

returns

vi is /usr/bin/vi
vim is /usr/bin/vim

and

echo $PATH

returns

/usr/local/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/lib/python2.7/site-packages:/Users/carlo/android-sdk-macosx/platform-tools:/Users/carlo/android-sdk-macosx/tools

I effed up my settings when I was screwing around with MacVim and Homebrew. And now I can't even start vim with vi or vim.

Best Answer

Set your path to be the following and then you should have temporary control (or just unset the $PATH and type things in exactly like /usr/bin/vi whatever)

 export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

Once you've confirmed all is well, you'll want to sort out the scripts that run each time you log in and set $PATH or just be sure that you delete things from /usr/local to clean up the problems.