Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Python 3 support with Vim 8 using Homebrew

When installing Vim on Mac OS with +python3 support I get the following error:

% brew install vim --with-python3
Usage: brew install [options] formula

...

Error: invalid option: --with-python3
like image 702
mattr Avatar asked Nov 24 '19 16:11

mattr


People also ask

Does vim support python3?

[vim/vim] Vim requires +python or +python3 even when installing with python support, installing with yum the syntax.

How do I know if Vim supports Python?

Run :ve[rsion] in command-line mode or run vim --version from Bash. If vim was compiled with Python 3, you'll find -python and +python3 . If vim was compiled with Python 2, you'll find +python and -python3 . If vim was compiled without Python support, you'll find -python and -python3 1.


1 Answers

+python3 is now enabled by default on Vim via Homebrew as of 2019. Older instructions out on the internets are not accurate (and I will not link to them to avoid raising their search ranking).

Simply install/upgrade via Homebrew:

% brew uninstall vim # optional, only if you previously installed it 
% brew install vim

Verify +python3:

% /usr/local/bin/vim --version
...
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           -python            +visual
+cmdline_info      +libcall           +python3           +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
...

Note, you still will have the system default Vim installed and it may be in your PATH before your Homebrew installed version, so if you do vim --version and it doesn't show +python3:

  1. try restarting your terminal
  2. try alias vim=/usr/local/bin/vim
  3. try adjusting your PATH variable to put Homebrew's Vim first. "editing PATH variable on mac" has additional information.
like image 142
mattr Avatar answered Sep 20 '22 04:09

mattr