I am trying to modify fortran syntax using a color scheme file.
In color scheme, these functions works fine.
hi! link fortranConditional Function
hi! link fortranRepeat SpecialChar
hi! link fortranBoolean SpecialChar
hi! link fortranReadWrite SpecialChar
hi! link fortranIO SpecialChar
hi! link fortranConstant Underlined
I want to add more element into different syntax keywords too. But for now, I can only use file type auto command like this:
autocmd BufNewFile,BufRead *.f90 syn match fortranType "[()]"
autocmd BufNewFile,BufRead *.f90 syn match fortranIntrinsic ":"
autocmd BufNewFile,BufRead *.f90 syn match fortranConstant "[%,]"
Is there any way that I can write autocmd BufNewFile,BufRead *.f90
only for once? Or is there other way I can add elements in color scheme files? Or the right way to do this is to create a new syntax file?
The direct answer to your question for grouping is to create a function and call that function:
autocmd BufNewFile,BufRead *.f90 call LoadFortranSyntax()
function! LoadFortranSyntax()
syn match fortranType "[()]"
syn match fortranIntrinsic ":"
syn match fortranConstant "[%,]"
endfunction
However the recommended and proper way of adding something to a syntax file, is using your ~/.vim/after/syntax
directory. For example:
File: ~/.vim/after/syntax/fortran.vim
syn match fortranType "[()]"
syn match fortranIntrinsic ":"
syn match fortranConstant "[%,]"
This is described in the help, under the topic mysyntaxfile-add
.