How to Enable Syntax Highlighting in Vim


There are a few different ways to enable Syntax Highlighting in Vim.

Option 1 – Edit ~/.vimrc

Add syntax on to your local ~/.vimrc

echo "syntax on" >> ~/.vimrc

Option 2 – Override System Vim (Mac)

cd
vim --version
xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew install vim --override-system-vim
vim --version

Option 3 – Toggle in Vim

You can use Vim Commands while in Vim itself:

:syntax on