How do I enable syntax highlighting for groovy in Vi?
Solution 1
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
Solution 2
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
Solution 3
https://ls3.io/post/jenkinsfile_vim_highlighting/
Solution in this link works for me.
executing below code. It also works in VI
echo 'au BufNewFile,BufRead Jenkinsfile setf groovy' >> ~/.vimrc
Solution 4
Or in vim editor type:
:syn on
Related videos on Youtube
Ant's
Updated on September 17, 2022Comments
-
Ant's over 1 year
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?
-
Yona Kim almost 6 yearsThis is for making vim open by default all files with the specific filename of "Jenkinsfile" with syntax highlighting of groovy.