Vim syntaxfile: Difference between revisions
From wikinotes
No edit summary |
|||
Line 10: | Line 10: | ||
<blockquote> | <blockquote> | ||
<syntaxhighlight lang="vim"> | <syntaxhighlight lang="vim"> | ||
if exists("b:current_syntax") | if exists("b:current_syntax") | ||
finish | |||
endif | endif | ||
" Define marker colours (CLI/GUI) | |||
let s:todo_colour = 'magenta' | |||
let s:gui_todo_colour = '#F57900' | |||
let b:current_syntax = " | |||
" Define Regexes | |||
let s:todo_regex = '\(^\s*\)\@<=\*\([a-zA-Z]\)\@!' | |||
" Define syntax for Regexes | |||
execute "syntax match todolistsimple_todo '". s:todo_regex ."'" | |||
" Apply highlighting | |||
execute ' highlight todolistsimple_todo ctermfg='. s:todo_colour .' guifg='. s:gui_todo_colour .' ctermbg=none cterm=bold gui=bold' | |||
" Register filetype (ex. ft=todolist_simple) | |||
let b:current_syntax = "todolist_simple" | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Example --> | </blockquote><!-- Example --> |
Revision as of 22:51, 2 October 2022
This tutorial looks really good
http://jeromyanglim.blogspot.com/2011/04/case-study-in-customising-syntax.html
TODO:
pick apart my vimscripts and fill out this article.
Example
if exists("b:current_syntax") finish endif " Define marker colours (CLI/GUI) let s:todo_colour = 'magenta' let s:gui_todo_colour = '#F57900' " Define Regexes let s:todo_regex = '\(^\s*\)\@<=\*\([a-zA-Z]\)\@!' " Define syntax for Regexes execute "syntax match todolistsimple_todo '". s:todo_regex ."'" " Apply highlighting execute ' highlight todolistsimple_todo ctermfg='. s:todo_colour .' guifg='. s:gui_todo_colour .' ctermbg=none cterm=bold gui=bold' " Register filetype (ex. ft=todolist_simple) let b:current_syntax = "todolist_simple"