簡體   English   中英

vim 語法突出顯示:以“#”開頭並以“#”或行尾結束的區域

[英]vim syntax highlighting: region that starts with "#" and end with either "#" or end of line

情況

我正在為一種允許遵循此方案的內聯注釋的語言編寫一個 vim 語法文件:

This is code # and here is comment # but this is code again

該語言還允許注釋以“#”開頭並以換行符結尾,如下所示:

This is code # and until the end of the line, this is a comment

我想要的是

我希望它們都被我的語法文件識別為注釋。

我試過的

當我使用時:

syn region comment start="#" end="#"

,結果是注釋沒有用換行符分隔。 現在,我做了一些研究並嘗試使用以下正則表達式匹配:

syn match comment "#.+?(?=#|$)"

這似乎工作正常,但沒有做我想要的。 它確實以第二個“#”結束內聯評論,但隨后從該主題標簽開始新評論,直到換行符。 正則表達式測試結果

如何告訴 vim 語法文件正確識別注釋?

這個很簡單

syn region Comment start=/#/ end=/#/ end=/$/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM