Last post, I talked about command-frequency-mode - both how to set it up and what it does. After I executed approximately 150000 commands, I found the most frequent ones, hoping to discover inefficiencies among my editing style that I could fix. This post has the top 10 different types of commands I tend to use, as long as subcommands and default keybindings. If you’re looking for a list of possible commands to use, you can just use these tables to increase your emacs knowledge. You can find more about these commands with C-h f, describe-function, and entering the command name.
The most frequent type of commands I use are, of course, related to inserting text. Self-insert-command is the basic command that insertion keys are bound to, which merely inserts the character pressed into the current location. The other input commands on the list are related either to inserting newlines, or special insert commands that do things such as indent the current line as well as insertion. Comint-send-input, for example, will execute the command you typed in as well as entering a blank line. Many of these commands will indent as well as adding a newline. indent-new-comment-line will also continue comments.
Movement commands are next frequent. These are mostly standard movement keys - either moving to the next of previous line, word, character, or paragraph are all standard commands that are some of the first you learn. Back-to-indentation I use probably more than most people, since I have it rebound to C-a instead of having that be the default key beginning-of-line. I tend to go to the end and beginning of buffer quite a bit, so these showed up.
Various ways of deleting text came in as the next most popular character. Most of these are more standard commands that everyone should know, and the various equivalents in other modes. Kill-line does sometimes act differently than most people expect, not killing newlines by default, but I prefer it’s default behaviour in most cases. It will kill from point to end of line, allowing you to replace whatever you just deleted.
These commands all relate to switching buffers and opening new windows. This allows you to have multiple buffers open and displayed at a time, to switch which buffers are displated, and create and kill existing buffers. These are not commands I’d expect beginning emacs users to learn, but I’d recommend anyone using emacs seriously to learn how to at least split the screen and use multiple buffers at a time. Most of these are Ido commands, which I talk about in my blog post here, but worse versions of the commands are available with the same keybindings if you haven’t enabled Ido.
Incremental search is just amazing. If you want to search for a word in your buffer, you can just press ‘C-s’ and start typing, and it will search as you type. C-s will go to the next match, and C-r will reverse direction and search backwards. You can also grab the word under point with C-w once you have entered isearch-mode by pressing C-s. The one thing that suprised me here was the large portion of abort-recursive-edits, since I almost never intentionally enter recursive edits.Recursive edits allow you to essentially suspend a search, edit the buffer some, and then resume the search. I should probably use these more than I do, but aborting recursive edit’s shouldn’t account for .42% of my commands.
Now we’re getting to categories that are less than 1% of my total editing commands. These commands all involve using previously-entered data, either by undoing or using previous history. Undo works differently in emacs than most editors; in emacs, you can undo to any point in your editing of a buffer, one command at a time. However, there is no redo; if you want to redo, you need to perform a command and then undo twice after undoing. This will first perform the command, undo the command, and then undo the first undo. I really think there should be some type of redo command, but I’ve tried to implement it and it’s unfortunately rather difficult to get one that works well. The other two commands are all more standard terminal history commands, with shell-mode and slime specifically.
Completion is another task I use a fair amount. One thing that immediately springs to mind is that yasnippet isn’t used at all here; I should make more extensive use of this. Pabbrev I’ve talked about here, and the other two commands in this category are fairly standard completion commands - comint-dynamic-complete is standard terminal tab-completion, whereas most people have probalby encountered minibuffer completion.
These are just miscellaneous commands that didn’t really fit into any category. Saving the buffer, setting the mark, M-x, C-y, and M-w are all command any basic emacs user should know. The cua-paste and cua-copy-region are just cua’s rebindings of kill-ring-save and yank, which function in pretty much the same way. Eval-last-sexp and slime-eval-last-expression are commands that are very useful for editing lisp; they will evaluate the expression right before point. Dired-mark is a dired command I’ve blogged about here.
Looking over these, there are several inefficiencies I noticed in the way I use emacs.
1) I use next-line and previous-line far too much. These should not be 10% of the commands I issue each. If I am moving around the buffer this much, I should learn more efficient ways to do so - either by using search more, or prefix keys, or just using forward-paragraph more.
2) My most frequent deletion command is by far deleting a single character. I find it hard to believe that this is the most common situation by that much, which means I should be using either kill-word more, or being more efficient at learning when i should mark a region and kill a region that way instead of just backspacing over it.
3) For someone who doesn’t consciously remember *ever* using a recursive edit in the time period I was recording this, I use way too many abort-recursive-edit calls. I need to find out how I’m entering recursive edits, and do that less. I’m not precisely sure how I’ll do this - maybe by defadvicing the recursive edit entry to notify me when it happens - but it really is something I should work on.
Even fixing just these three things seems likely to increase my editing proficiency with emacs by around 5%, so I think this was a valuable exercise. I highly recommend you doing the same - the process is described in my last blog entry, and it is quite simple to have runing for a few weeks while it gathers statistics. I’m probably going to do this again in a few months, hopefully once I’ve fixed or at least improved upon the three issues mentioned above.