How do I enable syntax highlighting for groovy in Vi?

I was using Fedora for about six months, and recently switched to Ubuntu.

Here in Ubuntu, there is no code/syntax highlighting for groovy in Vi editor, which was actually there in Fedora Vi. How to enable that?

0

4 Answers

Vim usually comes with syntax highlighting default to on.
Vim decides the syntax highlighting to enable, according to the file type (according to the file extension)
If you wish to enable syntax highlighting for a file which does not have a groovy extension you can manually set the syntax highlighting like so:

:set syntax=groovy

If you want to make a certain file name always open with the matching syntax highlighting, add something like this to your .vimrc:

autocmd BufNewFile,BufRead Jenkinsfile set syntax=groovy

To enable syntax highlighting in vim you have to enable it through .vimrc.
Add:

syntax on

to your .vimrc.

Here is the typical script for groovy. I do not know if it is compatible with vi or not because I am also novice to vi/vim. You can install the full vim with:

sudo apt-get install vim
1

Solution in this link works for me.

executing below code. It also works in VI

echo 'au BufNewFile,BufRead Jenkinsfile setf groovy' >> ~/.vimrc
1

Or in vim editor type:

:syn on
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like