Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make gvim markdown highlight ignore internal markers

I recently upgraded to gvim 7.3 and was pleased to find markdown highlighting. I also noticed that it treats "internal" _(underscore) as a marker. For example:

I want gvim to display emphasis here

but not_here

gvim actually displays the last line in my example as 'but not_here". It looks like SO's markdown interpretation is closer to what I want.

I do not say that gvim is "wrong" because I do not know what the correct markdown implementation is. However, is there a way to configure it so that the markers should be treated as normal text if they are surrounded by non-whitespace?

like image 214
Masked Man Avatar asked Nov 30 '12 16:11

Masked Man


2 Answers

The runtime files (especially if you use the old Vim 7.3.000 / 046 installer found on vim.org) aren't updated frequently. Most plugin authors publish more recent releases elsewhere, and they are only occasionally picked up by Vim.

In Tim Pope's repository, you'll find a newer version (that you can install into your ~/.vim directory) that doesn't show the problem; instead, it even highlights the single underscore character as an error.

like image 92
Ingo Karkat Avatar answered Oct 30 '22 03:10

Ingo Karkat


I have found a solution, which works in the things I have tested sofar.

Copy the %vim%/syntax/markdown.vim file into %/.vim/syntax/markdown.vim and change line 63 into:

syn region markdownItalic start="\s_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart

Restart vim and it should match *this* and _this_ but not_this.

EDIT: Changed information, thanks to @ZyX

like image 40
Wouter J Avatar answered Oct 30 '22 03:10

Wouter J