Vim syntax highlighting of inline markdown - vim

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.

Related

Let Vim interpret and highlight code comments/docs as markdown [duplicate]

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).

Vim: What's the best way to have markdown automatically enabled for comments?

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).

How can I hightlight markdown in doxygen under vim?

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).

Enabling markdown highlighting in Vim

I'm using Vim in a terminal on my MacBook Air with OS X Lion, and I can't seem to find a good plugin for Markdown syntax highlighting.
So far I've tried the plasticboy plugin and Tim Pope's plugin. The plasticboy plugin worked OK but was causing white space at the end of lines to be highlighted, and I haven't figured out how to turn that off. (It's really annoying, because every time I hit space when I'm writing it highlights the character.)
Tim's plugin didn't seem to do very much in the way of highlighting, other than maybe headers that use ###. Code blocks and bullets are ignored. I might be missing something there. I do use the .md extension on my Markdown files, so it should be picking up the filetype.
I've also seen a reference to Vim 7.3 having Markdown support built in, but without one of those two plugins I don't get any highlighting at all.
Do either of these require specific color schemes to work?
About the native syntax highlight for markdown I think it only works for files with the extension .markdown by default.
I was having problems with markdown syntax highlight for my .md files.
I tried:
:set syntax=markdown
And it worked.
So i included the following line in my .vimrc:
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
Now my vim have syntax highlight for my .md files.
BufFilePre is needed for :sav
Native syntax highlighting
Native syntax highlighting for Markdown only works by default for the .markdown file extension.
The following line in .vimrc yields the best results for both vim and gvim:
autocmd BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
Explanation:
1. Specify your Markdown flavour!
If you work with mainly one flavour of Markdown (e.g. Pandoc), be sure to mention this as well! Doing so, allows for mixing and matching of both Markdown- and Pandoc-specific Vim plug-ins. For example: I have found the vim-pandoc-syntax plug-in particularly suitable for my highlighting needs. Nevertheless, I use the more general vim-markdown-folding for Markdown folding.
By the way, only one flavour is allowed, separated by a dot, e.g.: filetype=markdown.pandoc
2. gvim requires BufFilePre
gvim requires an additional BufFilePre in the autocommand line for Markdown file type recognition with the Save As… :sav command.
This should work to disable the end-of-line space highlighting when using the plasticboy mkd plugin:
:syn clear mkdLineBreak
You could autocmd that for the necessary file extensions so that you needn't do it every time you load a markdown file.
Note that this specific highlight exists because Markdown treats lines ending with 2 or more space characters specially by inserting a <br>, so it is useful.
The plasticboy plugin uses TODO highlighting for this rule, which is a bit too much as it's designed to, by default, be really garish - yellow background - so that it stands out. You can make this less visually striking by changing that highlight rule. One quick way to do this would be something like:
:hi link mkdLineBreak Underlined
Now those end-of-line spaces will show up as underlined. Try linking to other highlight groups for something that may appeal to you more. Instead of using link you can get even more specific about those end-of-line spaces: for instance you could specify that they show up as just slightly lighter/darker than the normal background, using your own highlight command, specifying custom ctermfg, ctermbg, guifg, guibg settings.
As above, you could autocmd this to apply your specific settings.
For more information about link highlight groups, type: :help group-name and you'll see a list of groups that can be linked that themselves should helpfully be displayed using their current highlight rules. Also: :help highlight.
In Tim's plugin the .md extension works only for README.md because filetype.vim specifies so.
" Markdown
au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,README.md setf markdown
If you don't like putting all of your configuration in ~/.vimrc, you can create ~/.vim/ftdetect/markdown.md (or its equivalent on Windows) with the following contents.
au BufNewFile,BufRead *.md setf markdown

Vim plugin for coloring macros

Is there any way to highlight defined variables or macros in Vim? Is there any plugin which does that. For example:
#define MONITORING_OFF 0
change_monitoring(MONITORING_OFF);
In the above example, is there any way to highlight MONITORING_ON?
(I am using Vim on windows with ctags enabled.)
Thanks
It is worth to mention Easytags plugin that, in addition to automatic
tags file update, supports dynamic syntax highlighting of tags occurrences.

Resources