Configure Vim on Mac/Linux

Posted by Cooper on March 2, 2021

Vim - the ubiquitous text editor

Vim is a configurable text editor built to make creating and changing any kind of text very efficient. It is included as vi with most UNIX systems and with MacOS.

Installation

To install the latest Vim version, use homebrew:

1
brew install vim

SpaceVim

SpaceVim is a vim configuration inspired by spacemacs, it is compatible with vim and neovim.

Install SpaceVim

1
curl -sLf https://spacevim.org/install.sh | bash

Then all plugins will be downloaded automatically by running vim.

Configuration

The default configuration file of SpaceVim is ~/.SpaceVim.d/init.toml.

Use Vim as a Python IDE

For full tutorial, please see here. Alternatively, you can configure Vim as a C/C++ IDE.

Enable language layer

The python language support in SpaceVim is provided by lang#python layer, and it is not enabled by default. You need to enable it in SpaceVim configuration file. Press SPC f v d to open the SpaceVim configuration file, and add following snippet to your configuration file.

1
2
[[layers]]
  name = "lang#python"

Select a Python interpreter

Python is an interpreted language, and in order to run Python code and get semantic information, you need to tell SpaceVim which interpreter to use. This can be set with python_interpreter layer option. For example:

1
2
3
[[layers]]
  name = 'lang#python'
  python_interpreter = 'D:\scoop\shims\python.exe'

Uninstallation