Here’s a tiny tip. By default C-x k
runs the command kill-buffer
which prompts you for which buffer you want to kill, defaulting to the current active buffer. I don’t know about you, but I rarely want to kill a different buffer than the one I am looking at, so I rebind C-x k
to kill-this-buffer
which just kills the current buffer without prompting (unless there are unsaved changes).
Just add this to your emacs config file
(global-set-key (kbd "C-x k") 'kill-this-buffer)
Update 2017-04-24
Commenter thbit points out that using kill-this-buffer
in this way is unstable (see discussion here). Here is a safer alternative.
(defun bjm/kill-this-buffer () "Kill the current buffer." (interactive) (kill-buffer (current-buffer))) (global-set-key (kbd "C-x k") 'bjm/kill-this-buffer)