12

Ctrlk将删除从光标当前位置到行尾的所有内容。删除从当前位置到行首的所有内容是否有某种等价性?

4

3 回答 3

14

为我Ctrl-0Ctrl-k做你想做的事。我认为这是默认配置,当然不是我修改过的。

如果这不起作用,请尝试Ctrl-u0Ctrl-k。同样,这似乎是我安装时 Emacs 的默认行为(Emacs 24.x、Mac OS X)。

于 2013-07-02T18:01:39.660 回答
0

6Emacs 有陡峭的学习曲线。当一个新用户遇到这个问题时,她应该录制一个包含 2 次击键的宏:Shift+Ctrl+a 和 Ctrl-w(剪切),命名它,保存它,并设置一个键绑定,以便宏在随后的 Emacs 会话。

于 2013-07-02T18:03:44.350 回答
0

如果您希望使用较少的键绑定(而不是使用单独的键来删除行,或者必须调用前缀参数)。您可以使用crux-smart-kill-line 它将“杀死到行尾并在下一次调用时杀死整行”。但是,如果您喜欢delete而不是kill,则可以使用下面的代码。

对于点到字符串操作(杀死/删除),我建议使用zop-to-char

(defun aza-delete-line ()
  "Delete from current position to end of line without pushing to `kill-ring'."
  (interactive)
  (delete-region (point) (line-end-position)))

(defun aza-delete-whole-line ()
  "Delete whole line without pushing to kill-ring."
  (interactive)
  (delete-region (line-beginning-position) (line-end-position)))

(defun crux-smart-delete-line ()
  "Kill to the end of the line and kill whole line on the next call."
  (interactive)
  (let ((orig-point (point)))
    (move-end-of-line 1)
    (if (= orig-point (point))
        (aza-delete-whole-line)
      (goto-char orig-point)
      (aza-delete-line))))

资源

于 2019-04-04T03:31:12.860 回答