Vim (Vi IMproved) is one of the most widely used text editors on Linux and Unix-like systems. It comes with a lot of powerful features on top of the classic vi editor, including syntax highlighting, which makes your code or configuration files much easier to read by colouring different elements based on their type.
If you’re someone who edits scripts, configuration files, or source code regularly, enabling syntax highlighting can be a big productivity boost. This makes it easier to read, debug, and organize your work. For some users, colored text is helpful, while others may prefer plain, uncolored text. Luckily, Vim lets you turn on or off color syntax highlighting in vi or vim text editor on a Linux or Unix-like operating system option with just a few simple commands.
In this guide, we’ll explain how to:
- Turn on syntax highlighting (temporarily and permanently)
- Turn it off when you don’t need it
- Set a default color scheme for Vim
How to Turn ON Color Syntax Highlighting in Vim
If you want to enable the vim syntax colours option only for the current session:
Method 1: Enable Temporarily
Open any file in Vim, for example:vim ~/.vimrc
Press ESC and type::syntax on
If that doesn’t work, try::set syntax=on
This will colorize the code until you exit Vim. Once you close the editor, the setting is lost.
Method 2: Enable Permanently
To make syntax highlighting always available whenever you open Vim:
Edit your ~/.vimrc file:vim ~/.vimrc
Add the following line at the end:syntax on
Save and close the file.
Now, every time you launch Vim, syntax highlighting will be enabled automatically.
How to Turn Off Syntax Highlighting in Vim
If you prefer to work without colored text:
While inside Vim, press ESC & Type::syntax off
This will disable highlighting for the session. To keep it off permanently, add syntax off in your ~/.vimrc file.
How to Use a Vim Color Scheme
Vim also supports different color schemes to customize the look and feel of your editor, which change the way syntax highlighting looks.
To find installed colour schemes, you can check them in the following path:/usr/share/vim/vim*/colors/
To list available colour schemes, run:ls -l /usr/share/vim/vim*/colors/
Sample outputs:
total 56
-rw-r--r-- 1 root root 2476 Sep 27 01:43 blue.vim
-rw-r--r-- 1 root root 2990 Sep 27 01:43 darkblue.vim
-rw-r--r-- 1 root root 548 Sep 27 01:43 default.vim
-rw-r--r-- 1 root root 2522 Sep 27 01:43 delek.vim
-rw-r--r-- 1 root root 2812 Sep 27 01:43 desert.vim
-rw-r--r-- 1 root root 1666 Sep 27 01:43 elflord.vim
-rw-r--r-- 1 root root 2452 Sep 27 01:43 evening.vim
-rw-r--r-- 1 root root 1958 Sep 27 01:43 industry.vim
-rw-r--r-- 1 root root 3555 Sep 27 01:43 koehler.vim
-rw-r--r-- 1 root root 2460 Sep 27 01:43 morning.vim
-rw-r--r-- 1 root root 2006 Sep 27 01:43 murphy.vim
-rw-r--r-- 1 root root 1037 Sep 27 01:43 pablo.vim
-rw-r--r-- 1 root root 2673 Sep 27 01:43 peachpuff.vim
-rw-r--r-- 1 root root 2904 Sep 27 01:43 README.txt
-rw-r--r-- 1 root root 1393 Sep 27 01:43 ron.vim
-rw-r--r-- 1 root root 2720 Sep 27 01:43 shine.vim
-rw-r--r-- 1 root root 2445 Sep 27 01:43 slate.vim
-rw-r--r-- 1 root root 1629 Sep 27 01:43 torte.vim
-rw-r--r-- 1 root root 1840 Sep 27 01:43 zellner.vim
From the above output, let use pablo color scheme type the following in vim text editor::colorscheme pablo
You can try others (like desert, elflord, etc.) until you find one that fits your style.




