Skip to content

Comprehensive Guide to Installing Vim and Neovim on macOS

Published: at 04:10 PMSuggest Changes

Introduction

Vim and Neovim are powerful text editors that are essential tools for developers, system administrators, and power users. This guide will walk you through installing both editors on macOS.

Prerequisites

Installing Vim

# Update Homebrew
brew update

# Install Vim
brew install vim

Method 2: Using Built-in macOS Vim

macOS comes with a pre-installed version of Vim. Check the version:

vim --version

Verifying Vim Installation

# Open Vim
vim

# Exit Vim
:q

Installing Neovim

Step 1: Install via Homebrew

# Install Neovim
brew install neovim

Step 2: Verify Installation

# Check Neovim version
nvim --version

Basic Configuration

Vim Configuration

Create or edit Vim configuration file:

# Create .vimrc in your home directory
touch ~/.vimrc

# Open .vimrc with Vim
vim ~/.vimrc

Example minimal configuration:

" Enable syntax highlighting
syntax on

" Show line numbers
set number

" Enable mouse support
set mouse=a

" Indentation settings
set tabstop=4
set shiftwidth=4
set expandtab

Neovim Configuration

Create Neovim configuration:

# Create Neovim config directory
mkdir -p ~/.config/nvim

# Create init.lua configuration file
touch ~/.config/nvim/init.lua

Example minimal Lua configuration:

-- Enable line numbers
vim.wo.number = true

-- Set tab width
vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.o.expandtab = true

-- Enable syntax highlighting
vim.cmd('syntax enable')

Vim Plugins (using vim-plug)

# Install vim-plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Neovim Plugins (using packer.nvim)

# Install packer.nvim
git clone --depth 1 https://github.com/wbthomason/packer.nvim\
 ~/.local/share/nvim/site/pack/packer/start/packer.nvim

Troubleshooting

Conclusion

You’ve now installed both Vim and Neovim on your macOS system. Explore their extensive features and customize them to boost your productivity.

Further Reading


Next Post
How to Install Homebrew on macOS - The Ultimate Package Manager