如果我映射 ddkP,Vim 会吃掉我所有的行
在 Vim 中,我设置了一个映射,每次按 _
时都会移动一行
nnoremap _ ddkP
在我的实验中,当我到达 Vim 文件的顶部时,所有如果我继续按住_
,线条就会被吃掉,
有什么问题吗?我使用的是 Mac,但使用控制台 Vim,而不是 MacVim。
In Vim, I set a mapping to move a line up with each press of _
nnoremap _ ddkP
In my experiments, when I reach the top of my Vim file, all the lines get eaten up if I continue to press and hold _
Is something wrong? I'm on the Mac, but using the console Vim, not MacVim.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
k
(上移一行)在文件顶部时失败。我怀疑这会导致映射键执行停止,只剩下 dd (删除当前行)。要解决此问题,您需要一种破坏性较小的方式来移动线路。The
k
(move up one line) fails when at the top of a file. I suspect this causes the mapped keys execution to stop, leaving you with justdd
(delete current line). To fix this, you'll need a less destructive way to move the line.克里斯托的解释对我来说看起来很合乎逻辑。
我建议您尝试使用此映射,它会执行
:move
而不删除任何行:
您也可以原子地撤消此操作。
Kristo's explanation looks logical to me.
I suggest that you try this mapping instead, which does a
:move
without deleting any lines:You can also undo this atomically.