我已经使用vim几个月了,我已经习惯使用C和D来改变和删除从光标到行尾的所有内容.
考虑下面的行,光标在'bar'的'b'上:
foo.bar("hello world")
Run Code Online (Sandbox Code Playgroud)
在这一点击中D将产生:
foo.
Run Code Online (Sandbox Code Playgroud)
点击C将执行相同的加上开始插入模式,光标在句点之后.
但是,按Y不会做直观相似的事情(复制从光标到行尾的所有内容).相反,它复制整行(就像yy一样).
如何将Y从光标复制到行尾,而不是像yy一样复制整行?
从这个配置:
" make Y effect to end of line instead of whole line
map Y y$
Run Code Online (Sandbox Code Playgroud)
我怀疑默认行为仅仅是由于某些历史不一致.
nmap Y y$
这样做你想要的吗?
编辑
Y 和 yy 做同样的事情的原因可能与此有关:
{Visual}["x]y Yank the highlighted text [into register x] (for
{Visual} see |Visual-mode|). {not in Vi}
*v_Y*
{Visual}["x]Y Yank the highlighted lines [into register x] (for
{Visual} see |Visual-mode|). {not in Vi}
Run Code Online (Sandbox Code Playgroud)
Y 是用来作用于线条的, y 是用来作用于单个字符的?