8

Text marked as__bold__ or _italic_ appears in the same color as normal text.

Headings and code do show up in different colors, so vim correctly recognizes the file as markdown.

This is no matter what colorscheme I use.

Is it possible to make text marked as bold or italic in Markdown, highlighted in their own colors?

P.S. I'm using a full vim install (not vim-tiny) version 7.4 on Xubuntu Linux.

This is what it looks like. While the previous lines show that headings etc. work, line 22-26 contain text that should have been highlighted differently than the default - this is in :colorscheme default but it doesn't work in others either

enter image description here

  • If you think you can have some use for pandoc, you can check (at least) the syntax plugin: github.com/vim-pandoc/vim-pandoc-syntax . It will show bold as bold, italic as italic (or IIRC with different background color in terminals without italic support). Or at least you can check its syntax for hints. – VanLaser Sep 8 '15 at 17:43
  • What's the output of :verbose highlight htmlBold and :verbose highlight htmlItalic? These should be the default highlight groups if you're using the builtin markdown support. – zool Sep 9 '15 at 10:13
  • I have the same problem when I use vim from xterm with markdown or html files. But if I start tmux inside the same xterm it works as expected. Doing :set ft=html seems to fix it (the filetype already was HTML). :highlight htmlBold says cleared *but many other html* highlights are fine) ... Not sure what's going on here. – Martin Tournoij Sep 10 '15 at 0:13
  • @zool they both say xxx cleared - does that mean the builtin markdown support is not working? – LB7979 Sep 12 '15 at 12:42
  • @VanLaser I tried installing pandoc but couldn't get it to work... – LB7979 Sep 12 '15 at 12:47
5

Try something like that:

highlight htmlBold gui=bold guifg=#af0000 ctermfg=124
highlight htmlItalic gui=italic guifg=#ff8700 ctermfg=214
  • 2
    Sorry for this late reply, but just wanted to let you know that in the meantime I've had to reinstall Kubuntu (for reasons unrelated to the above issue) and in this completely fresh install of Kubuntu/konsole/vim the syntax highlighting works perfect. So the problem is solved, but I don't know what caused it in the first place, and unfortunately I can't let you know if your suggestion would have worked... – LB7979 Mar 15 '16 at 6:46
  • @LB7979 Ok, no problem. Good luck :). – A S Mar 15 '16 at 18:51
0

Looks like Vim default color schemes don't have the best support for markdown and use the HTML syntax file instead. That's probably causing your issue.

Try installing a maintained and popular color scheme instead. Solarized, Monokai and base16 are common choices.

  • I installed those colorschemes, but when I activate them within Vim, it gives many error messages Error detected while processing /usr/share/vim/vim74/colors/base16-eighties.vim: line 4: E477: No ! allowed: <!DOCTYPE html> line 5: E488: Trailing characters: <html lang= line 6: E488: Trailing characters: <head prefix= line 7: E488: Trailing characters: <meta charset='utf-8'> etc. Looks like it actually recognized it's not an html file. – LB7979 Sep 16 '15 at 10:22
  • LB7979 Well, it looks like you downloaded some HTML file, and not the colorscheme... I don't think this is your problem though, as bold text should always work regardless of colorscheme... – Martin Tournoij Sep 16 '15 at 14:19
  • @Carpetsmoker I think that's exactly the problem. The output of :verb hi htmlBold on my machine is this: ctermfg=3 guifg=#ebcb8b Last set from ~/.vim/bundle/base16-vim/colors/base16-ocean.vim, so the color gets clearly set by my color scheme. Please compare my output to the one of @LB7979, where htmlBold xxx term=bold cterm=Bold gui=bold Last set from /usr/share/vim/vim74/syntax/html.vim. No mention of color highlighting in Vim's default HTML syntax. The bold setting is probably not working either cause bold text rendering is off by default in most terminal emulators. – zool Sep 17 '15 at 13:48
  • @LB7979 please try giving :hi htmlBold ctermfg=#ff0000 guifg=#ff0000 and check if bold text in your buffer turns red. – zool Sep 17 '15 at 13:52
  • @LB7979 Also, you can enable bold text rendering in iTerm2 by checking Preferences > Profiles > Text > Draw bold text in bold font – zool Sep 17 '15 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.