对于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-插入如下:
(define-key global-map [(meta insert)] 'vi-open-line)
对于dd
,如果您想让杀死的线路进入杀手环,您可以使用此功能来包装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
,这样它可以杀死比“当前”行更多的内容。
您也可以查看viper-mode
的来源,了解它如何实现等效的dd
,o
和O
命令。
来源
2010-01-31 21:20:32
seh
我认为最好的新方法是http://superuser.com/a/331661(C-e C-j) – 2014-01-09 07:08:48