3

Vim で言語の構文強調表示を拡張して、重要なコメントを目立たせる簡単な方法はありますか? たとえば、 で始まる行が C ファイルの通常のコメントを表す場合、 で始まる行をより目立つ色で強調表示し//たいと思います。//!!

// this is a regular comment - line color should be the default color for comments

//!! this is an important comment - highlight line in red
4

1 に答える 1

3
:syn match specialComment #//!!.*# | hi specialComment ctermfg=red guifg=red

Ingo Karkat が指摘しているように、.cファイルをロードした後にコマンドを実行するには、~/.vim/after/syntax/c.vim.

のようにすべてを 1 つのファイルにまとめたい場合は、別のオプションとして~/.vimrc、コマンドをバッファーの enter イベントにバインドすることもできます。

au! BufEnter *.c syn match specialComment #//!!.*#  " C files (*.c)
au! BufEnter *.py syn match specialComment /#!!.*/  " Python files (*.py)

...

hi specialComment ctermfg=red guifg=red
于 2012-12-24T05:51:39.203 に答える