[英]vim vnoremap: E488 Trailing characters
I'm using vim to program and I just want to make a shortcut for comment. 我正在使用vim进行编程,我只想提供一条注释的快捷方式。
Here is how I set in .vimrc
: 这是我在.vimrc
设置的方式:
vnoremap <F7> :%s/^/\/\//g
I just want to add //
in front of each selected line. 我只想在每个选定行的前面添加//
。 However, when I press <F7>
and press Enter
in visual mode, I get an error: 但是,当我按<F7>
Enter
在可视模式下按Enter
时,出现错误:
E488 Trailing characters
Note that when you press F7
it just simulates pressing all the keys in the string. 请注意,当您按下F7
键时,它只是模拟按下字符串中的所有键。 As soon as it presses :
it gets into a state 按下时:
进入状态
:'<,'>
When it then types in all the rest of your command it gets into: 然后输入所有其余命令时,它将进入:
:'<,'>%s/^/\/\//g
Which is meaningless ( %
after '<,'>
doesn't make sense). 这是没有意义的(在'<,'>
之后'<,'>
%
没有意义)。 If you just remove %
from your command, it will already work. 如果仅从命令中删除%
,则该命令已经可以使用。 Even better, add <CR>
at the end so that you don't need to press Enter: 更好的是,在最后添加<CR>
,这样就无需按Enter键:
vnoremap <F7> :s/^/\/\//g<CR>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.