The newer version of doxygen comes with markdown support. Is there an easy way to add markdown syntax highlight to a doxygen comment block in vim?
On a side note, one can add doxygen syntax to a c file by using set filetype=c.doxygen
To do this right, the Doxygen syntax extension script would need to be extended to support Markdown syntax, either by duplicating the syntax, or by defining regions that can include Markdown and using :syntax include syntax/markdown.vim to include the syntax. Please contact the syntax plugin's owner with such a request, or even send a patch.
For a pragmatic approach that you can immediately use, my SyntaxRange plugin provides a command that can highlight certain ranges with a different syntax:
:3,11SyntaxInclude markdown
With this (possibly aided by a custom mapping to make this faster), you can highlight Doxygen-Markdown ranges on demand (e.g. when the text markup is so complex that you would have the comfort of proper syntax highlighting).
Related
While using https://github.com/plasticboy/vim-markdown I discovered that markdown headers are html identifiers. An h2 markdown header has two identifiers tied to it: ['mkdNonListItemBlck', 'htmlH2'].
I'm unsure if I'm able to "double" match and define the colors for that selection or if I should only execute htmlh2 highlighting if the file is of type markdown.
If you want to adapt the colors, you need to find out which syntax group causes the highlighting. It's easier when you install the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin. Or just try which :highlight command changes the colors.
Many syntax scripts are hierarchical, i.e. a text is matched by multiple syntax rules. Without looking deeply into this particular Markdown syntax, I'd guess mkdNonListItemBlock is a generic block, and htmlH2 comes from the original HTML syntax.
Rephrasing my last question: I only want to highlight htmlH2 if I'm in a markdown file. I was hoping to "double" match both groups and then set the highlight preference.
That's unfortunately not possible. Highlight groups like htmlH2 are global; that's why the convention prefixes them with the filetype (html). If you redefine the colors, that will always apply to both HTML and Markdown.
You could write :autocmd WinEnter to toggle them back and forth between HTML and Markdown buffers (and never view both in splits at the same time), or copy-and-paste the syntax stuff from syntax/html.vim into syntax/mkd.vim and then rename htmlH2 to mkdH2, but I wouldn't recommend either hack.
I would like to be able to format comments in code somewhat:
# **TODO**
#
# *Don't forget*
I want markdown syntax to be highlighted a bit but only in comments, add cterm=bold for \*\*(.*)\*\* or something.
Is there a way to do it in Vim?
To do this properly, you'd have to :syntax include the markdown syntax into each individual syntax (that has comments that you're interested in), and have it containedin= the corresponding syntax group for comments. That's doable, but requires some effort (depending on how many and which syntaxes to modify).
It's quicker to use a plugin like my SyntaxRange plugin to change the syntax of those comment blocks to markdown (manually, and on demand). With a corresponding mapping, this can be set up quite easily (but it's not automatic as the first alternative).
The newer version of doxygen comes with markdown support. Is there an easy way to add markdown syntax highlight to a doxygen comment block in vim?
On a side note, one can add doxygen syntax to a c file by using set filetype=c.doxygen
To do this right, the Doxygen syntax extension script would need to be extended to support Markdown syntax, either by duplicating the syntax, or by defining regions that can include Markdown and using :syntax include syntax/markdown.vim to include the syntax. Please contact the syntax plugin's owner with such a request, or even send a patch.
For a pragmatic approach that you can immediately use, my SyntaxRange plugin provides a command that can highlight certain ranges with a different syntax:
:3,11SyntaxInclude markdown
With this (possibly aided by a custom mapping to make this faster), you can highlight Doxygen-Markdown ranges on demand (e.g. when the text markup is so complex that you would have the comfort of proper syntax highlighting).
Is there any current vim plugin that allow me to highlight markdown text in a comment block of any arbitrary languages. And is that possible?
Have a look at my SyntaxRange plugin. It is based on Different syntax highlighting within regions of a file, and provides a :[range]SyntaxInclude markdown command as well as functions to do so programmatically.
I have a HTML file which contains both HTML and JavaScript. When I folded some code snippets, the syntax highlight didn't work well. Screenshot as following:
Line79 function setColor(color) is not correctly highlighted. Is there any way to fix it?
BTW, I am using GVIM 7.2 in windows 7.
Thanks!
When Vim opens an html file it applies html highlighting throughout the file. When you have a separate language in the html file you need to define syntax regions to let Vim know that parts of the file are to be highlighted differently from the language identified by the file extension. I described how to do this in an answer to an SO question here: In VIM, how can I mix syntax/ident rules of both jinja and javascript in the same file?
Also review the docs at :h syn-include.
Indenting is similar. That is, Vim will apply html indenting rules to everything within the file unless you tell it to indent the Javascript region differently.
NOTE: Maybe since html with embedded javascript is so common the html syntax files may by default support embedded javascript. The tip linked below suggests using :set filetype htmlm4 to get proper highlighting, although a commenter says that should not be necessary:
http://vim.wikia.com/wiki/Syntax_highlighting_for_HTML_with_embedded_Javascript
:syn sync fromstart
(See also help syn-sync-first)
It may be that you have a line in the mapInit() function whose length exceeds vim's 'synmaxcol' setting Notice the highlighting is incorrect on line 77 too (the closing brace).
set synmaxcol
From vim's help:
Maximum column in which to search for
syntax items. In long lines the text
after this column is not highlighted
and following lines may not be
highlighted correctly, because the
syntax state is cleared. This helps to
avoid very slow redrawing for an XML
file that is one long line.