Can't run vi from terminal
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.