简体   繁体   中英

Mac can't open system vim in terminal

I tried to upgrade my system Vim from 7.3 to a high version so I used macport to do that. This newer version is located in /opt/local/bin/ . Later I decided to uninstall it due to some reason.

Now I can't open my system Vim in the terminal, the error message is -bash: /opt/local/bin/vim: No such file or directory . Somehow the machine still thinks the vim is located in /opt/local/bin/ .

Then weird thing happens, when I type which vim , it shows my vim located at /usr/local/bin , and there is indeed a vim folder in that directory, but I can't open it by typing vim in the terminal.

So here is the situation: I have two working versions of Vim in my machine, a 7.3 version in /usr/bin and a 7.4 version in /usr/local/bin (I don't know how I got this one). Both working (I have to type the whole directory /urs/bin/vim or /urs/local/bin/vim ), but can't be opened in the terminal by simply typing vim .

Updates:

now I can use vi or vim , but the problem is, the former opens 7.3 whereas the latter opens 7.4

At the current command window, type:

$ hash -r

then try running vim again. Or create a new window and try in that.

Bash remembered where vim was found, and expects to find it there again. When you removed vim , it got upset and complained (rather than try to find it again before complaining). Using hash -r vim forgets all previously hashed commands and then finds vim explicitly. Run hash with no options to see what it knows.

See the Bash manual on hash for more information.

The default Vim is /usr/bin/vim . There is absolutely no reason whatsoever to change it.

If you want a more up-to-date Vim, install MacVim and use the bundled mvim script instead of vim .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM