I am on Mac, El Capitan.
Here are my code:
My question is: how many vim do I have? I know that:
/usr/bin/vim is from Mac OSX
/usr/local/bin/vim is from Homebrew
/usr/local/Cellar/vim/xxx/bin/vim is also from Homebrew (?)
Also:
So another question: Which one should I use, if I want to use brew to upgrade it.
You should use the one in /usr/local/bin by making sure your PATH environment variable includes /usr/local/bin before /usr/bin.
If you look carefully, you will see that /usr/local/bin/vim is a symbolic link to homebrew's Cellar and each time you update vim in homebrew it will update the symlink in /usr/local/bin to point to the latest version in its Cellar. So, if you use /usr/local/bin/vim you will always be using the latest.
Let's check that:
ls -l /usr/local/bin/vim
lrwxr-xr-x 1 mark admin 30 21 Jul 18:25 /usr/local/bin/vim -> ../Cellar/vim/7.4.2033/bin/vim
Yes, /usr/local/bin/vim points to /usr/local/Cellar/vim/7.4.2033/bin/vim and that is why you get the same version when you run both commands - because they are the same thing.
The Apple-shipped version is ancient - you don't want that.
Related
I know that I have Node installed but I don't remember if I used NVM, Brew or if I downloaded it from the official Node website.
Is there any command I can use to figure out how I installed it in the first place?
Note: I use a zsh shell on macOS
A good indicator is to check where it is installed:
ls -l $(which node)
For brew, this will yield something like
lrwxr-xr-x 1 flyx admin 30 Sep 12 17:02 /usr/local/bin/node -> ../Cellar/node/16.9.1/bin/node
NVM seems to install it somewhere in ~/.nvm but I don't know the specifics. I have no idea what the installer does.
I'm seeing something very odd, and honestly I'm stumped.
The version of vim that comes with mac is outdated (7.3 instead of 7.4). I'm trying to install vim from homebrew, and I want to use that one instead of the default apple version.
I ran "brew install vim". It installed correctly in /usr/local/bin/vim. All good.
When I run "which vim", it prints "/usr/local/bin/vim". The Apple version of vim is installed at /usr/bin/vim. So the which command is telling me that I'm using the homebrew version of vim.
However, when I actually run vim, it still runs the Apple version
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 9 2015 23:58:42)
Compiled by root#apple.com
...
If I run the homebrew version explicitly, I see this:
$ /usr/local/bin/vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 23 2015 18:16:35)
MacOS X (unix) version
Included patches: 1-898
Compiled by Homebrew
...
I even tried moving /usr/bin/vim to /usr/bin/vim73 to try to force using the homebrew version. However, when I did this, here is what I see when I try to run vim:
$ vim --version
-bash: /usr/bin/vim: No such file or directory
$
What is going on? How can I get it to run the homebrew version of vim?
Start a new shell session and it’ll work.
Bash caches executables’ paths so when you run vim it looks at your PATH to find the first executable with this name. It caches it and the second time you run vim it remembers vim is actually /usr/bin/vim and runs that.
Since you haven’t restarted your Bash session its cache is still the same; hence the error you’re seeing. It has nothing to do with the way you installed vim.
If you don’t want to start a new shell session, you can run hash -r to tell Bash to clear its executables memory.
You forgot an argument:
$ brew install vim --override-system-vi
I tried to install YouCompleteMe on Mac for vim, but I've been using the system vim which is version 7.3. I tried to update my vim using homebrew by typing brew install vim and everything seemed to be fine.
When I type vim I still see the system vim loading (version 7.3).
I feel like I'm missing a step that's keeping me from using the updated vim I got from homebrew. Does anyone know what I'm missing?
For reference when I type which vim I get the following output /usr/bin/vim. Any help would be greatly appreciated.
Just install vim via homebrew:
brew install vim
Then restart your shell:
exec -l $SHELL
And check the version:
$ vim --version|head -n 1
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 9 2016 19:07:39)
You should probably have done brew install vim --with-override-system-vi. This will replace default vim path.
You're loading your system vim first, as you can see by which vim returning /usr/bin/vim instead of /usr/local/bin/vim.
/usr/local/bin is homebrew's path.
Make sure that your path lists /usr/local/bin before /usr/bin:
/usr/local/bin:/usr/bin
This will allow homebrew's vim to be sourced before the system vim.
To view your path:
echo "$PATH"
Rather than reinstalling vim you can move your current vim to vim73 (or something similar).
First check if /usr/local/bin is present in PATH environment variable. Doing echo $PATH on your terminal should do that.
Install vim with homebrew if you haven't already.
brew install vim
Then move your current vim installation.
mv /usr/bin/vim /usr/bin/vim73
Run which vim to confirm. It should say /usr/local/bin/vim.
brew install vim --with-override-system-vi (missing the with-)
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
Run this command and it will be fixed.
I installed macvim using homebrew on my Mackbook Pro (lion). once that was installed I installed janus. I also installed oh-my-zsh (if that helps solve this problem).
I can't seem to get ctags working though. In MacVim when I do Tools>Build Tags File I get:
:!ctags -R .
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
shell returned 1
Press RETURN or type command to continue
How do I get it to work?
Here's some additional info that may help you:
✗ ctags --version
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Jul 7 2012, 01:00:53
Addresses: <dhiebert#users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: +wildcards, +regex
✗ which ctags
/usr/local/bin/ctags
✗ echo $path
/Users/adam/.rvm/gems/ruby-1.9.3-p194#gemset/bin /Users/adam/.rvm/gems/ruby-1.9.3-p194#global/bin /Users/adam/.rvm/rubies/ruby-1.9.3-p194/bin /Users/adam/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/X11/bin /Users/adam/.rvm/bin
It definitely looks like Vim is picking up /usr/bin/ctags, which doesn't recognize -R, instead of /usr/local/bin/ctags. This can happen if put /usr/local/bin in your path only for login shells.
You might want to make sure /usr/local/bin gets added to your path in the non-login, non-interactive environment file. I don't use zsh myself, but it looks like that would be .zshenv.
On a mac, by default the path that vim uses and the path that the terminal (bash/zsh) uses are different, so even if you have the correct path set in the terminal, it won't translate to vim correctly, to rectify this situation, you need to run
sudo chmod ugo-x /usr/libexec/path_helper
For more information see: How to use correct ruby in vim ? How to modify $PATH in VIM?.
I'm on OS X 10.7 with Vim 7.3.
I'd like to install the breakindent patch.
Here's a way to do it on Linux with apt-get:
Compiling VIM with breakindent patch.
How do I do this? I suppose it will involve building Vim via Homebrew (which is OK with me).
Use Mercurial to get the latest Vim source code:
$ hg clone https://vim.googlecode.com/hg/ vim
$ cd vim
Grab the patch.
Apply the patch as indicated in the linked thread:
$ patch -p1 < /path/to/breakindent.patch
Configure Vim with the options you need (python/ruby support, custom location, etc.):
$ ./configure --with-features=huge <other options>
Build and install:
$ sudo make && make install
I just modified the Homebrew formula for MacVim to optionally add that patch. If you want to try it out, you can download the formula at https://gist.github.com/4108848 and plunk it in /usr/local/Library/Formula; then install using brew install --with-breakindent-patch macvim.
(EDIT: I used to have a link to my GitHub fork of Homebrew here, but I've decided to delete that fork unless I actually submit anything to Homebrew. The old formula could optionally add a patch that's been added to the main Vim since then.)
As of June 25th 2014, VIM includes the breakindent patch by default – finally :-)
For more info, see https://retracile.net/blog/2014/07/18/18.00
If you're installing from Homebrew, use:
brew install macvim --with-features=huge --override-system-vim --HEAD