As an ordinary hardcore Emacs user, I only use the mouse when is absolutely necessary. In fact I removed the top menu and the tool bar from the stock interface many, many years ago:

'(menu-bar-mode nil nil (menu-bar)) 
'(tool-bar-mode nil nil (tool-bar))

Not liking the mouse, there are the two basic things you have to do to keep using Emacs in a productive way: memorize tons of keyboard shortcuts and knowing your way with the M-x commands.

But the above two things lead to lots of typing. And I don’t like typing a lot either (…no one does…). But the good thing is that Emacs has plenty of interesting packages to help reduce the amount of typing that one has to do to complete the usual editing tasks.

One of those packages is Ido which I’ve been using for quite a few years now.

 (require 'ido) 
 (ido-mode t) 
 (setq ido-enable-flex-matching t) ;; enable fuzzy matching 
 ;; idomenu 
 (autoload 'idomenu "idomenu" nil t)

The typical things you can achieve with Ido are:

  • easily switch between buffers with “C-x b” (M-x ido-switch-buffer), by just typing a few characters that from the buffer name. Ido will interactively show in the echo area the buffer names matching the characters just typed.
  • similarly, you can easily find a file using “C-x C-f” (M-x ido-find-file)and then typing some characters appearing in the file name. Ido will interactively list in the echo area the file names from the current directory that match the characters that you just typed.
  • in the same way, you can easily kill a buffer using “C-x k” (M-x ido-kill-buffer) and then typing some characters appearing in the buffer’s name.
  • I also use idomenu.el, which does the same trick to easily jump to any function or heading in the source code or text file in the buffer that you are currently editing.

But it is until recently that I noticed smex.

;; Smex(require 'smex)(smex-initialize)(global-set-key (kbd "M-x") 'smex)(global-set-key (kbd "M-X") 'smex-major-mode-commands);; This is your old M-x.(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)

Smex is another fine Emacs package built on top of Ido which helps with the two little actions that you need to perform when you don’t know or don’t remember the keyboard shortcut, namely, finding and typing the corresponding M-x command. Smex will do the following for you:

  • list in the echo area the M-x commands that match the characters that you type as you type them.
  • And additionally, it shows the most recently used commands first, in case you need to invoked them again.

Those two little things combined save valuable time that you learn to appreciate very quickly because you are able to minimize your brain’s context switching time, which is the most successful way of destroying a programmer’s focus.

Finally, there are a number of other packages that offer similar functionality:

  • iswitchb: Among other things, this package provides M-x iswitch-kill-buffer which does the same job as M-x ido-kill-buffer.
  • icicles: This package is similar in essence to Ido, however it is much more generic and big and the interface is a little bit different. Normally, you use one or the other but not both at the same time. I’ve tried it in the past, but I found its interface and general feeling less intuitive than Ido. However, I’m know this is because I didn’t give it enough time to completely adjust to its philosophy.