How to Enable Syntax Highlighting in Vim

In this tutorial, we will quickly show you how you can enable and configure syntax highlighting in Vim. Whether you are running Vim on Windows, macOS, or Linux.
Captain Salem 2 min read
How to Enable Syntax Highlighting in Vim

Vim is one of the powerful and popular text editor among developers, geeks, sysadmins, and terminal users. It comes packed with lots of features that take it from a mere text-editor to a full blown IDE depending on your environment choice and configuration.

However, there is one feature that is universal across development requirements, and that is syntax highligting.

Syntax highlighting is a great way to make the code more readable and easier to work with. It also makes the code look more visually appealing than staring at a bunch of white text on black background.

Luckily, Vim comes with built-in support for syntax highlighting for a wide range of programming languages and file types.

Open Vim

First, open a terminal and launch Vim by typing vim followed by the name of the file you want to edit.

vim audio.js

Enable Syntax Highlighting

By default, Vim should have syntax highlighting enabled. However, if it's not enabled or if you want to ensure it's active, you can explicitly enable it by running the following command within Vim:

Ensure you are in command mode before running the above command. You can enter vim command mode by pressing the esc key.

:syntax enable

The command above tells Vim to enable syntax highlighting for the current buffer.

Set the Syntax Highlighting Color Scheme (Optional)

Vim allows us to customize the color scheme used for syntax highlighting.

We can choose from a variety of pre-defined color schemes or create your own. To set a color scheme, use the following command within Vim:

:colorscheme <scheme_name>

Replace <scheme_name> with the name of the color scheme you want to use.

You can list available color schemes by typing :colorscheme and pressing Tab for autocompletion.

For example:

:colorscheme retrobox

If you wish to define or download custom colorschemes, can find Vim colorschemes in the link below:

Trending vim color schemes | vimcolorschemes
Check out the Trending vim color schemes! | vimcolorschemes is the ultimate resource for vim users to find the perfect color scheme for their favorite development environment. Come for the hundreds of vim color schemes, stay for the awesome hjkl spatial navigation.


Congratulations! You've successfully enabled and customized syntax highlighting in Vim. You can now enjoy a more visually appealing and productive coding experience in Vim.

More from GeekBits

Join us at GeekBits

Join our members and get a currated list of awesome articles each month.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to GeekBits.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.