Vim syntaxfile: Difference between revisions
From wikinotes
No edit summary |
|||
Line 1: | Line 1: | ||
Syntax for writing vim syntax-files. | |||
= Documentation = | |||
<blockquote> | |||
{| class="wikitable" | |||
|- | |||
| <code>:h syn-match</code> || https://vimhelp.org/syntax.txt.html#%3Asyn-match | |||
|- | |||
| <code>:h syn-region</code> || https://vimhelp.org/syntax.txt.html#%3Asyn-region | |||
|- | |||
|} | |||
</blockquote><!-- Documentation --> | |||
= Locations = | |||
<blockquote> | |||
{| class="wikitable" | |||
|- | |||
| <code>${vim-or-plug}/syntax/${vim_filetype}.vim</code> || syntax files | |||
|- | |||
|} | |||
</blockquote><!-- Locations --> | |||
= Example = | = Example = |
Revision as of 14:55, 30 July 2023
Syntax for writing vim syntax-files.
Documentation
:h syn-match
https://vimhelp.org/syntax.txt.html#%3Asyn-match :h syn-region
https://vimhelp.org/syntax.txt.html#%3Asyn-region
Locations
${vim-or-plug}/syntax/${vim_filetype}.vim
syntax files
Example
" ftdetect/todolist_simple.vim au BufRead,BufNewFile *.todo set filetype=todolist_simple" indent/todolist_simple.vim let b:did_indent = 1 setlocal autoindent setlocal indentexpr= setlocal tabstop=4 setlocal softtabstop=4 setlocal shiftwidth=4 setlocal expandtab" syntax/todolist_simple.vim 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"