Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

vimの簡易Markdownハイライト設定

More than 3 years have passed since last update.

最新のvimだとmarkdownのシンタックスファイルが存在していますが、少し古いvimを使う機会が多く、プラグインも入れられる環境にないため、いつでも使えるように自分でシンタックスを作成してみた。
vimの知識が不足しているので、つたないものになっていますが、自分がmarkdownを書く時の見た目としては十分かなーという程度のモノです。

""" MarkDownの簡易ハイライト設定
augroup simpleMarkdownHighlight
  autocmd!
  " シンタックス範囲定義
  autocmd VimEnter,WinEnter *.md syn sync minlines=500 maxlines=1000
  " コードブロック
  autocmd VimEnter,WinEnter *.md syn match mdCodeDelimiter "^```.*" contained
  autocmd VimEnter,WinEnter *.md syn region mdCode start="^\s*```.*" end="^\s*```" keepend contains=mdCodeDelimiter
  " 見出し
  autocmd VimEnter,WinEnter *.md syn match mdH "^#\+.\+$"
  " リスト
  autocmd VimEnter,WinEnter *.md syn match mdList "^ *[\-\+\*] "
  " 順序付きリスト
  autocmd VimEnter,WinEnter *.md syn match mdNumList "^ *\([0-9]\+\.\)\+ "
  " リンク
  autocmd VimEnter,WinEnter *.md syn match mdLinkDelimiter "[()\[\]]" contained
  autocmd VimEnter,WinEnter *.md syn region mdId start="\[\(?=.+?\](\)" end="\]" keepend nextgroup=mdLink skipwhite contains=mdLinkDelimiter
  autocmd VimEnter,WinEnter *.md syn region mdLink start="(" end=")" keepend contained contains=mdLinkDelimiter
  " 引用
  autocmd VimEnter,WinEnter *.md syn match mdBlockQuote "^> .\+$"
  " カラースキーマ定義
  autocmd Colorscheme * highlight def link mdH Title
  autocmd Colorscheme * highlight def link mdCodeDelimiter Special
  autocmd Colorscheme * highlight def link mdList CursorLineNr
  autocmd Colorscheme * highlight def link mdNumList CursorLineNr
  autocmd Colorscheme * highlight def link mdCode Comment
  autocmd Colorscheme * highlight def link mdBlockQuote Constant
  autocmd Colorscheme * highlight def link mdLink Underlined
  autocmd Colorscheme * highlight def link mdId Type
  autocmd Colorscheme * highlight def link mdLinkDelimiter cleaned
augroup END
laikuaut
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away