For some people VIM is the primary code editor and some people use it to make minor edits to their code. Whatever your use case might be, it’s always good to have some syntax highlighting. It makes the code more readable and reduces errors.
Syntax highlighting / Color coding is not turned on MAC by default. Turning it on is a very simple task.
Open your terminal, it will be in Applications/utilities folder.
Type in the following command to open up the VI editor preferences file
Most probably it will be empty. Whether its empty or not, add this code at the very end.
filetype plugin indent on syntax on
Bonus tip: If you are wondering how we got the line numbers in the above screenshot
- Press the Esc key if you are currently in insert or append mode.
- Press : (the colon). The cursor should reappear at the lower left corner of the screen next to a : prompt.
- Enter the following command: set number.
- A column of sequential line numbers will then appear at the left side of the screen.
You can even add
set number at the end of above two lines in ~/.vimrc to make it always show the line numbers.