Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using an external syntax highlighter in vim

Tags:

vim

I have access to a syntax highlighting program for an internal-only language. Is there any way in which I could get vim to call this program to perform syntax highlighting? I figure that it's worth seeing if this is possible before I write my own syntax file, since it's quite complex (not to mention prone to change). The program in question could be quite easily customized to output in a new intermediate format (it's only currently outputting HTML), if that would make things easier.

like image 931
Derek Thurn Avatar asked Mar 18 '11 16:03

Derek Thurn


People also ask

How do I enable syntax highlighting in vim?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.

Does vim support syntax highlighting?

VIM is an alternative and advanced version of VI editor that enables Syntax highlighting feature in VI. Syntax highlighting means it can show some parts of text in another fonts and colors. VIM doesn't show whole file but have some limitations in highlighting particular keywords or text matching a pattern in a file.

How do I highlight keywords in vim?

Press 1 to highlight the current visually selected text, or the current word (if nothing is selected). Highlight group hl1 is used. Press 2 for highlight hl2 , 3 for highlight hl3 , etc. Press 0 to remove all highlights from the current visually selected text, or the current word.


1 Answers

I would suggest to write a quick throwaway script in the language of your choice to convert the output of the program in question to the Vim highlighting syntax. You mentioned the program is prone to change, but its output format can be easily customized: using your own conversion script (which parses the programs output format) you could easily stay up-to-date with the latest changes (just run your script again). And as others have mentioned: creating a new syntax file is really easy in Vim, so it's up to the complexity of the programs output how hard this actually is.

like image 199
akosch Avatar answered Oct 22 '22 18:10

akosch