Some Useful Emacs Commands

I have been using Emacs for editing source code, and have found that I can do things faster and faster the more I use the program. If I then go and use an IDE such as the new Qt Creator (which has vi but not emacs key bindings as an option) I am incredibly frustrated that I have to use the cursor keys, can’t kill a line with C-k, and so on. I keep learning new useful commands; here are 3 that aren’t in the O’Reilly Gnu Emacs book that are very helpful:

C-x C-o deletes multiple blank lines and leaves just one blank line. If you have too many blank lines between function definitions, for example, this cleans them up.

M-spacebar does a similar job to extra white space between words. If you are moving text around and are left with a big chunk of white space between two words, just put your cursor in the space and use this command to shrink it down to one space.

C-x z repeats the last command, whatever it was. It is different from C-x ESC ESC which repeats the last command using the minibuffer (i.e. the last “complex” command). You can keep hitting the z key after the first z to repeat again and again.

I’m not an Emacs wizard. Emacs Lisp still frightens me. But as an old Wordstar user (my first word processor) the use of control and alt-key combinations to manipulate text is a familiar, even comfortable concept. I know enough vi commands to get by, but nothing seems to beat the power of Emacs in my opinion.

By mannd

I am a retired cardiac electrophysiologist who has worked both in private practice in Louisville, Kentucky and as a Professor of Medicine at the University of Colorado in Denver. I am interested not only in medicine, but also in computer programming, music, science fiction, fantasy, 30s pulp literature, and a whole lot more.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.