开发者

Emacs: what is the shortcut key to clear buffer?

Like, Control-A (select all开发者_Python百科) followed by delete?


How about using:

M-x erase-buffer

Which you could bind to whatever you want.


C-x h + del key clears the buffer

Note: This requires transient-mark-mode to be enabled (which it is by default).


Select all in Emacs is:

C-x h

(technically, that's mark-whole-buffer) and kill-region (to kill the marked region, which is now the entire buffer) is:

C-w

If you want to delete the region without copying it to the kill-ring, you can use

M-x delete-region

instead. If you do this alot, you'll want to bind delete-region to a key/key combo.


These macros build on the answers given above. To start using them paste them into your .emacs then restart emacs or (while in the .emacs buffer) type M-x eval-buffer.

(defun clear-buffer ()
  "clear whole buffer add contents to the kill ring"
  (interactive)
  (kill-region (point-min) (point-max))
  )

(defun clear-buffer-permenantly ()
  "clear whole buffer, contents is not added to the kill ring"
  (interactive)
  (delete-region (point-min) (point-max))
  )


Old folks might like to call it hk rather than clear-buffer-permanently, and assign it to the nostalgic key sequence like so:

(define-key esc-map "\^[hk" 'hk)

That's the pre-Gnu TECO EMACS command to clear the buffer (ESC ESC wHole Kill).


Go to the begin of the buffer, go to the end (both set the mark), then cut:

M-< M-> C-w


There is no shortcut, but you can define one... Follow this link to get a macro for clearing a buffer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜