逃避.vimrc中的双引号

Gav*_*vin 3 vim

我想添加这个映射:

map <C-K> "_dd
Run Code Online (Sandbox Code Playgroud)

如何逃避双引号,以免被解释为评论?

Jos*_*Lee 8

我觉得你会好的.

从手册:

                                                        *:quote*
'"' at the start of a line causes the whole line to be ignored.  '"'
after a command causes the rest of the line to be ignored.  This can be used
to add comments.  Example: >
        :set ai         "set 'autoindent' option
It is not possible to add a comment to a shell command ":!cmd" or to the
":map" command and friends, because they see the '"' as part of their
argument.
Run Code Online (Sandbox Code Playgroud)

注意它命令之后是如何表达的- 不幸的是,很难说出命令结束的确切含义.有些命令(:edit)只接受一个参数,而其他命令(:map,:help)可以使用该行上的所有内容.

换句话说,使用":map应该工作正常,没有任何特殊处理,我会坚持这作为指导.如果您发现它将其视为"注释的开头,则只需使用反斜杠:\".