Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
    
What does this command return: type -a vi vim ? What about echo $PATH ? –  glenn jackman Jun 3 '13 at 18:49
    
@glennjackman I added the output of these two commands in the question. –  Nicolás Carlo Jun 3 '13 at 18:54
    
What about these: ls -l /usr/bin/{vi,vim}; hash -t vi vim –  glenn jackman Jun 3 '13 at 18:59
    
@glennjackman thanks. bmike's answer below fixed the problem for me. –  Nicolás Carlo Jun 3 '13 at 19:00

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
THANK YOU! That works. Do these settings go in a specific file that I can take a look at? For example, when I execute the command above, what file changes that makes the settings change? –  Nicolás Carlo Jun 3 '13 at 19:00
    
Why not spin that second question off on how to determine which startup files are being run. My guess is you'll need to list the OS version, homebrew version and perhaps look into what exact shell you use if you are not using bash (the default shell). –  bmike Jun 3 '13 at 19:01
    
Alright. Thanks for the answer though. –  Nicolás Carlo Jun 3 '13 at 19:02
    
A;sp note if you have /opt/local/bin you have also been playingwith Macports and only one of Macports or Homebrew should be used or you get issues similar to this –  Mark Jun 3 '13 at 19:49
    
Might want to look at your ~/.bash_profile to check for any settings that might conflict. –  Gregg Leventhal Jun 3 '13 at 20:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.