As you know that the ctags in OSX is a basic version, and I install a full version of ctags using homebrew, but when I wanna use it in Vim's command mode, it always ran the basic one. So I checked the $PATH var in Vim's command mode, like !echo $PATH, and it showed that /usr/local/bin followed the /usr/bin, which was different from the shell environment $PATH, so please kindly tell me how to fix this, many thanks!.
BTW, I changed the $PATH in vimrc file, but it only affected the $PATH if I type the command echo $PATH in Vim's command mode, not !echo $PATH.
Unfortunately, MacVim won't be affected by paths you set in .profile or .bashrc.
You can set paths affecting all programs on Mac OS X by using the /etc/paths and /etc/paths.d/ mechanisms. More detailed explanation here:
https://serverfault.com/questions/16355/how-to-set-global-path-on-os-x
Related
Getting Broken Pipe when executing tmux command from profile on iterm2.
When I execute tmux from command line there is no problem.
>echo $PATH
>/Users/myname/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/tmux:/usr/local/MacGPG2/bin
The path seems to be ok.
Any idea how to fix that ?
The solution was adding full path to the command
/usr/local/bin/tmux
TL;DR: You do not have /usr/local/bin/ in path, only /usr/local/bin/tmux.
/usr/local/bin/tmux is not a directory, it is an executable.
$PATH searches all its directories in the order specified for an executable that you're looking for. There is no tmux inside /usr/local/bin/tmux, so it doesn't find anything there.
You need to make your path include /usr/local/bin
I am not sure I understand correctly from the readme file how to install vim onto my mac. After installation, I still cannot seem to open files while typing gvim HelloWorld.c into terminal. How can I permanently fix the gvim command for terminal to recognize all the time?
Mac OS X already ships with a slightly underpowered but perfectly working vim build so you only have to issue that command in your terminal:
$ vim filename
MacVim is a more featureful version that comes with a GUI and a CLI executable. Is that what you installed?
The archive you downloaded contains MacVim.app and a shell script called mvim.
If you don't plan to use Vim in or from your terminal, you don't need that mvim script at all.
If you do, the simplest solution is to put that script somewhere in your $PATH. To do so, check the value of $PATH with the following command:
$ echo $PATH
and copy the script into one of the listed directories:
$ cp /path/to/mvim /some/directory/mvim
After that's done, you can call the MacVim GUI from your terminal with:
$ mvim filename
or the MacVim CLI with:
$ mvim -v filename
I got a new machine at work. The previous developer had macvim installed. When typing 'vim' in the terminal, the macvim program would open. I uninstalled macvim because I don't use it. Now when I type 'vim' in the terminal, it says, "Sorry, cannot find MacVim.app." I want to just run vim in the terminal. Is this an alias or something? How can I quickly fix!
you can enter this into the terminal:
which vim
alias
to see info about defined aliases and what happens when you try to run vim
The previous user installed the mvim script that comes with MacVim somewhere in the $PATH or elsewhere and probably symlinked it or created an alias.
To get rid of that behaviour, try the following:
look into your ~/.bashrc or whatever if there's an alias that point at mvim
look everywhere in your $PATH for a mvim script, maybe
$ which mvim
will do
make sure /usr/bin/vim is a real Vim executable and not a symlink with this command
$ file /usr/bin/vim
If it's symlinked then you have trouble, If it's only an alias simply remove it. If you don't want to mess around too much, you can add an alias to /usr/bin/vim in your ~/.profile or whatever.
Whatever you do, I'd recommend you to re-install MacVim as it is a lot better than the default Vim in almost every way.
Is there still a file here: /usr/bin/vim ?
If that got deleted, then you'll need to reinstall vim.
I suggest using Link as your package manager
e.g.,
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/bin:~/bin:/usr/local/Cellar/python3/3.2.3/bin
$ vim
:! echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:~/bin:/usr/local/Cellar/python3/3.2.3/bin
I expected them to be the same. Why are they different?
If it makes a difference, here is my shell, vim version and OS version:
$ echo $SHELL
SHELL=/usr/local/bin/zsh
$ /usr/local/bin/zsh --version
zsh 5.0.0 (x86_64-apple-darwin12.0.0)
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 20 2012 13:16:02)
Compiled by root#apple.com
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.8.2
BuildVersion: 12C60
(Mountain Lion)
This is a known
problem introduced by
Apple in OS X 10.5 Leopard.
If you are using Bash or Zsh and are using non-interactive shells, you
are affected.
Running sudo chmod ugo-x /usr/libexec/path_helper will fix you up,
but you should take a look at the article to see why.
From this SO answer
There are many similar questions on stackoverflow and stackexchange.
Your shell executes different *rc files depending on the arguments its given at launch time. Therefore, you need to setup Vim so that it launchs your shell with the right arguments.
The following helps in bash, I'm almost certain there's a similar flag in zsh.
set shell=bash\ -i
See $ man zsh for the right flag and the right execution order.
I was not able to resolve this with zsh, and ended up using bash for my vim shell.
Here's what I did:
modified my .zshrc to work with bash
ln -s .zshrc .bashrc
added set shell=bash to my .vimrc file
and now my vim command-line PATH is equal to my zsh shell PATH.
I don't use mac or zsh (I am on linux), however I ran into this problem when I ran gvim from the MATE Menu.
I solved it by adding this to my .vimrc:
if $PATH !~ "\.rbenv"
let $PATH="/home/username/.rbenv/shims:/home/username/.rbenv/bin:" . $PATH
endif
This avoids setting it if you run vim from a terminal, otherwise the rbenv paths would be included twice.
I tried setting the application to run via a terminal, but that didn't help.
I would like vim to point to macvim :)
Probably through an alias.
vim is here: whereis vim
/usr/bin/vim
macvim I can't find, e.g.
whereis macvim returns nothing
The MacVim distro comes with a script called mvim that takes exactly the same arguments as vim. Put mvim somewhere in your path. Then, just set the alias: alias vim='mvim'
If you want to completely override the system vim, an easy way is to use Homebrew. Just install MacVim with $brew install macvim --override-system-vim. The --override-system-vim flag will create mvim symlinks to vi, vim, etc. You may find it a cleaner way to achieve the same goal. Plus, I prefer to use Homebrew as a package manager.
EDIT: Since you say you don't know where MacVim is, you may just want to download the latest tarball for your system and start from scratch. There are three files: the MacVim application, the mvim script, and a README.
Put MacVim in your Applications folder. Put mvim somewhere in your path.
Going forward, you should look for mvim using which rather than whereis. E.g. $which mvim #=> /usr/local/bin/mvim
which returns the pathnames of the files which would be executed in the current environment. whereis checks the standard binary directories, and may miss files included in your personal path.
Alternately, use Homebrew, as I suggest above and it will manage the location of both files.
My answer is kind of the opposite of michaelmichael's and I've made it quite a few times:
MacVim comes with a CLI executable that you can use in place of Mac OS X's default Vim if you add a single alias to your ~/.bashrc/~/.profile. No need to compile anything, no need to put MacVim in a special place, no need to overwrite default programs with symlinks
This way, you can stay in CLI-land and enjoy the power of a powerful/recent/fast Vim.
EDIT
MacVim is a native Mac OS X GUI version of Vim. It doesn't come preinstalled with your OS so you have to download it from the Internet or install it through homebrew (see michaelmichael's answer). Once it's installed, MacVim is where you have put it, plain and simple.
Because it's a full fledged GUI app, MacVim can't really be used as a drop-in replacement for the default Vim in the terminal.
`$ MacVim file.txt` will not work. `$ open -a macvim file.txt` will not work either.
You basically have two options: use the mvim CLI wrapper to open MacVim from the terminal or use an alias to MacVim's bundled CLI executable.
The mvim wrapper
I think michaelmichael's answer could be a expanded a bit but the most important is said.
EDIT: well scratch that.
The bundled CLI executable
Just add this line (customized to reflect your system) to your ~/.bashrc or ~/.profile or whatever file is run by your shell at startup:
alias vim='/path/to/MacVim.app/Contents/MacOS/Vim'
Open a new terminal window, $ vim file.txt should launch vim in your terminal window, just like the default /usr/bin/vim but with a lot more bells and whistles.
After installing mvim, you can find where it is located with typing into terminal:
which mvim
On my system this gave me:
/usr/local/bin/mvim
Then you create an alias in .bash_profile by typing the following in your terminal, and hit enter:
echo alias vim='/usr/local/bin/mvim' >> .bash_profile
Restart your terminal and try typing:
vim .
This should launch mvim and not vim