Jus*_*rce 2 syntax vim comments
并非Vim中的每个命令都允许您添加行尾注释.有时"它作为一个参数是有效的,所以它是模棱两可的.但是,如果插入管道,命令将结束,您可以插入注释.因此,您实际上可以在vim中实现可靠的行尾注释:
noremap ' ` |" Use single quote as alternate range key
Run Code Online (Sandbox Code Playgroud)
干净吧?但该syntax/vim.vim文件并未将此视为行尾注释.我如何告诉Vim识别这种语法?
我发现这个syntax/vim.vim:
syn match vimLineComment +^[ \t:]*".*$+ contains=@vimCommentGroup,vimCommentString,vimCommentTitle
Run Code Online (Sandbox Code Playgroud)
我尝试将这样的东西加到我身上~/.vimrc,但没有效果.VimScript很难.:/
syntax match vimLineComment '|".*$+'
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
你不能使用maps 的内嵌评论
:h map-comments
Run Code Online (Sandbox Code Playgroud)
你会看见:
*map-comments*
It is not possible to put a comment after these commands, because the '"'
character is considered to be part of the {lhs} or {rhs}.
Run Code Online (Sandbox Code Playgroud)
我希望这回答了你的问题.
好的,你可能有充分的理由这样做.
只有定义syn match vimLineComment是不够的,你必须覆盖vimMapRhs语法.所以这两行将|"foo bar突出显示为评论:
syn match vimMapRhs '.*\ze|\s*".*'
syn match vimLineComment '|\s*".*$'
Run Code Online (Sandbox Code Playgroud)
这可能会改变"评论"的亮点,但我不建议这样做.