Vim syntaxfile: Difference between revisions

From wikinotes
No edit summary
Line 4: Line 4:
<blockquote>
<blockquote>
<syntaxhighlight lang="vim">
<syntaxhighlight lang="vim">
" ftdetect/todolist_simple.vim
au BufRead,BufNewFile *.todo set filetype=todolist_simple
</syntaxhighlight>
<syntaxhighlight lang="vim">
" indent/todolist_simple.vim
let b:did_indent = 1
" copy indentation from prev line
setlocal autoindent
setlocal indentexpr=
setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal expandtab
</syntaxhighlight>
<syntaxhighlight lang="vim">
" syntax/todolist_simple.vim
if exists("b:current_syntax")
if exists("b:current_syntax")
   finish
   finish

Revision as of 22:54, 2 October 2022


Example

" ftdetect/todolist_simple.vim

au BufRead,BufNewFile *.todo set filetype=todolist_simple
" indent/todolist_simple.vim

let b:did_indent = 1

" copy indentation from prev line
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"