Reputation: 11025
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?
Upvotes: 7
Views: 1832
Reputation: 2425
Try to use Github flavor markdown: https://github.com/jtratner/vim-flavored-markdown
Upvotes: 1
Reputation: 4989
I had these issues when documenting code in markdown files.
The solution I used was to put the offending sections in a codeblock with four spaces or in a code span with surrounding back ticks (`).
Upvotes: 2
Reputation: 41934
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
Upvotes: 4
Reputation: 172550
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.
Upvotes: 7