Emacs相当于Vim的dd,o,O
我目前正在玩emacs,并对大多数概念感到满意。但是我真的很喜欢三个vim命令的方便:dd,o,O
希望你能告诉我如何在emacs镜像他们:)
我发现了类似的做法:
虽然C-a将光标移动到行的开头,但第一个C-k会杀死文本,第二个则会杀死换行符。唯一的问题是,这不是在空线上工作,我只需要键入C-k,这是非常不方便的,因为我必须对同一个任务使用不同的命令:杀死一条线。
那么,C-C C-O几乎像O,只是身份丢失了。 C-e C-o在当前下方创建一个空行,但不会移动光标。 有什么更好的解决方案我的问题,还是我必须学习Lisp和定义新的命令来满足我的需要?
对于o和o,这里是几年前写的几个函数:
(defun vi-open-line-above () "Insert a newline above the current line and put point at beginning." (interactive) (unless (bolp) (beginning-of-line)) (newline) (forward-line -1) (indent-according-to-mode)) (defun vi-open-line-below () "Insert a newline below the current line and put point at beginning." (interactive) (unless (eolp) (end-of-line)) (newline-and-indent)) (defun vi-open-line (&optional abovep) "Insert a newline below the current line and put point at beginning. With a prefix argument,insert a newline above the current line." (interactive "P") (if abovep (vi-open-line-above) (vi-open-line-below))) 您可以将vi-open-line绑定到M-insert,如下所示: (define-key global-map [(meta insert)] 'vi-open-line) 对于dd,如果想要杀死的行将其置于kill ring上,可以使用包含kill-line的此函数: (defun kill-current-line (&optional n) (interactive "p") (save-excursion (beginning-of-line) (let ((kill-whole-line t)) (kill-line n)))) 为了完整,它接受一个前缀参数并将其应用于kill-line,这样它可以比“current”行多得多。 您也可以查看 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |