4

I realize syntax highlighting is not enabled when editing files in vim by default. How do I activate it?

1 Answer 1

10

Here's how to install syntax coloring in vim for Mac OS X Sierra/High Sierra:

1. Download a vim color scheme:

You can download one here: https://github.com/flazz/vim-colorschemes

2. Move color scheme into the colors directory inside your local .vim directory. (Create one if one does not exist.)

(Assuming scheme is in local Downloads folder) mv ~/Downloads/molokai.vim ~/.vim/colors/

Create the colors and ~/.vim directories if they do not exist: mkdir -p ~/.vim/colors/

3. Set syntax coloring in Mac OS X Sierra/High Sierra:

Run the following command in Terminal: set term=builtin_ansi

4. Update/Create local .vimrc file:

vim ~/.vimrc

Your .vimrc file should look similar to the following:

syntax on colo molokai 

5. Restart terminal

Sign up to request clarification or add additional context in comments.

2 Comments

You are changing the colorscheme not syntax highlighting. Syntax highlighting is done by :syntax enable
thank you - really helped. few comments (at least for Catalina): a. no need for step 3 enable syntax coloring; b. no need to restart terminal c. .vimrc file should look sdomething like syntax enable set t_Co=256 set background=light colorscheme clean

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.