要复制和粘贴一行我使用以下方法
C-a - beginning of line
#save the line to kill-ring using kill-line(this is faster than marking,
# move to end of line and C-w)
C-k - kill-line
C-/ - undo kill-line
# move point to required line
C-p or C-n or C-s (search for the nearest line where the paste must be done)
C-y # paste the line
是否有比这更有效的方法。在vim中输入 yy ,导航并 p 完成工作
答案 0 :(得分:2)
使用kill-whole-line
代替 C-a C-k 。它默认映射到 C-S-backspace 。
答案 1 :(得分:0)
使用evil-mode,只需使用默认的vim键绑定。http://wikemacs.org/index.php/Evil
否则,M-w
(kill-ring-save)会保存该区域。如果我们想要在没有选择区域的情况下复制当前行:
(put 'kill-ring-save 'interactive-form
'(interactive
(if (use-region-p)
(list (region-beginning) (region-end))
(list (line-beginning-position) (line-beginning-position 2)))))
(put 'kill-region 'interactive-form
'(interactive
(if (use-region-p)
(list (region-beginning) (region-end))
(list (line-beginning-position) (line-beginning-position 2)))))