mtk*_*mtk 15 vimrc block-comment
我不想评论文本文件或代码中的文本行。我正在寻找在.vimrc文件中插入块注释。插入单行注释"
使用,例如:
" remove spaces and tabs as well at the end of line automatically while saving
autocmd BufWritePre * :%s/\s\+$//e
Run Code Online (Sandbox Code Playgroud)
现在,我在浏览 Internet 以添加很酷的功能后,多年来收集了相对大量的设置/配置/插件。我希望在我的 .vimrc 文件中添加一些大的注释块。添加"
到每一行是一个选项,但我正在寻找块注释语法。类似于/**/
C.
//
等同于"
/* */
等同于_ ____?
搜索 Unix.SE、SO 和谷歌搜索并没有多大帮助。
我的解决方案是将代码包装在function
.
这在 vimrc 中效果很好,例如,对于就地heredoc语法突出显示测试,这也需要没有前导字符的真实块注释。在我的 vimrc 中,我在设置我的 heredoc SyntaxRanges后直接使用这样一个块。
function! _blockcomment()
" free text comment
You can write free text here,
but vim will try to highlight it as vimscript!
" markdown heredoc
test <<MD
### Nevertheless ###
* for testing my fuzzy SyntaxRange heredocs
* having no leading chars is essential
* and the blockcomment function does the trick
MD
endfunction
Run Code Online (Sandbox Code Playgroud)
此解决方案类似于@Stéphane 的if 0
技巧,但对我不起作用。只要确保永远不要调用这个函数!
我不认为这是可能的。您能做的最好的事情是阻止选择一些文本,然后s/^/"/
在 vim 中的第一个字符上进行搜索/替换以插入一个"
以在每行的开头。
vim 插件NERD Commenter也可能有助于使这更容易。