我试着这样做:
nnoremap B ^ " comments over here
nnoremap E $ " comments over here
这让我感到惊讶,因为没有工作;相反,B
和E
的行为变得非常不稳定。然后我尝试在这些命令之后删除空格:
nnoremap B ^" comments over here
nnoremap E $" comments over here
并修复了它。尾随空格对这些命令有什么影响?
答案 0 :(得分:3)
来自:help 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}.
所以......既不是
nnoremap B ^ " comments over here
,也不
nnoremap B ^" comments over here
可以按预期工作:第一个相当于输入
^<space><space><space><space>"<space>comments<space>over<space>here
,第二个相当于输入
^"<space><space><space><space>comments<space>ove<space>here
正如罗兰史密斯建议的那样,将你的评论置于你的映射之上。并避免尾随空格。
答案 1 :(得分:0)
重映射命令的参数是;
<buffer>
,<silent>
,
<expr>
,<script>
,<unique>
或<special>
)在定义原始映射后尝试调用:map
。您将看到空格和注释成为映射的一部分。这可能不是你想要的。
是的,我建议将注释放在映射命令之前的行上;
" Format the current paragraph
nnoremap <leader>f gqap
" Toggle line numbering.
nnoremap <c-n> :set number! number?<cr>