Home Linux Vim

Example to set .bk to highlight as a bash file

vim /etc/vimrc Syntax on au BufNewFile,BufRead *.bk set filetype=bash

Create your own syntax on a custom extension (raw) in this example

Create the syntax file ~/.vim/syntax/raw.vim " Vim syntax file " Language: jlweber raw files " Maintainer: Jean-Louis Girard " Latest Revision: 2018-08-16 if exists("b:current_syntax") finish endif " Regions " remove the escapes for code syn region jlcode start='<\code>' end='<\/code>' syn region jlh1 start='<h1>' end='</h1>' syn region jlh2 start='<h2>' end='</h2>' syn region jlh3 start='<h3>' end='</h3>' Create the filetype for vim ~/.vim/ftdetect/raw.vim autocmd BufRead,BufNewFile *.raw set filetype=raw Add the desired colors to the region matches in .vimrc set t_Co=256 highlight jlcode ctermfg=39 highlight jlh1 ctermfg=172 highlight jlh2 ctermfg=178 highlight jlh3 ctermfg=184