Vim syntax highlighting
Alright, this is probably a stupid question, but....
I've got a file of source code in a proprietary language. I want to edit said file with VIM, instead of their crummy editor. I'd like basic syntax highlighting of the language, but I don't want to spend a bunch of time rolling my own syntax file.
Therefore, does VIM have a basic source highlighting module? It doesn't need to be perfect, I just want it to cover simple things. Currently, my only choices are no syntax highlighting, pick a random language, or roll my own.
EDIT: Source code sample below
{
function letter do
gposition 0, 0
if gender = "M" do
if language = "SPA" OR state = "PR" do
%male spanish letter
gposition .26, .75
pdfimage "MALE SPANISH.pdf", 1, .93
setcolor truewhite
setfillmode 1
%whitebox
gposition 5.25, 1.25
rectangle 2.5, .5
开发者_运维百科
Could this be the correct language?
http://www.iml.ece.mcgill.ca/~stephan/node/17
Rolling your own syntax highlighting is not difficult at all and it would take a few minutes.
For example, I wrote a DSL (called Konira) that uses Python for the most part, but it fails at highlighting my custom DSL statements. This is how the "extra" highlighting looks:
function! KoniraSyntax() abort
let b:current_syntax = 'konira'
syn match KoniraIt '\v^\s+it\s+'
syn match KoniraSkipIf '\v^\s+skip\s+if'
syn match KoniraDescribe '\v^describe\s+'
syn match KoniraRaises '\v^\s+raises\s+'
syn match KoniraBeforeAll '\v^\s+before\s+all'
syn match KoniraBeforeEach '\v^\s+before\s+each'
syn match KoniraAfterEach '\v^\s+after\s+each'
syn match KoniraAfterAll '\v^\s+after\s+all'
hi def link KoniraSkipIf Statement
hi def link KoniraIt Statement
hi def link KoniraDescribe Statement
hi def link KoniraRaises Identifier
hi def link KoniraBeforeAll Statement
hi def link KoniraBeforeEach Statement
hi def link KoniraAfterAll Statement
hi def link KoniraAfterEach Statement
endfunction
As you can see above, I set the current syntax, then I match via regular expression those statements that I want, and the I apply the type of highlighting that I need on that match.
And you can call it as a regular function when you know (or if you able to detect) that you are editing such a source file:
call KoniraSyntax()
精彩评论