从当前位置删除到emacs中的行首?

时间:2013-07-02 17:57:52

标签: emacs

Ctrl k 会删除从光标当前位置到行尾的所有内容。是否有一些等价物可以删除从当前位置到行首的所有内容?

3 个答案:

答案 0 :(得分:9)

对我来说 Ctrl-0 Ctrl-k 做你想要的。我认为这是默认配置,它肯定不是我修改过的。

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

答案 1 :(得分:0)

6Emacs的学习曲线陡峭。当新用户遇到此问题时,她应该记录2个按键的宏:Shift + Ctrl + a和Ctrl-w(剪切),命名,保存,并设置一个键绑定,以便宏可用于随后的Emacs会议。

答案 2 :(得分: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))))

source

相关问题