Emacs's Command Frequency (Old)

By Xah Lee. Date: , 2008-09,

2010-02-13. This file is obsolete. For the latest version, please see: Emacs's Command Frequency.

This page lists emacs's commands in the order of their frequency of use.

In emacs, each key press actually invokes a command. (For example, pressing “a” actually invokes the command “self-insert-command”. Pressing 【Ctrl+f】 invokes the command “forward-char”. Pressing 【Alt+x】 invokes “execute-extended-command”. Pressing the invokes “forward-char”.)

The motive of this study, is in designing a ErgoEmacs Keybinding. I needed to know which command are actually more frequently used, in order to give it a easier-to-press keybinding.


The following frequency list is based 3 users. Xah Lee (me), Marc Shapiro, Rick Bielawski (aka rgb). The total count of all command calls is 203118. The following is a break down of each's data contribution:

Name       Command calls    Percentage
Rick            93 534          46%
Xah             82 090          40%
Marc            27 494          13%
total          203 118         100%

The total count of self-insert-command calls is 65 496. The following is a break down by that command.

Name         number of         Percentage
             command call     
Xah             29 758          45%
Marc            20 026          31%
Rick            15 712          24%
total           65 496         100%

Following is a table showing the proportion of each person's use of data-entry commands and non-data-entry commands. “data-entry” commands are the commands: “self-insert-command” (invoked by pressing a single letter/number/symbol key), “newline” (invoked by Enter/Return key). Basically, data-entry commands are just typing. All other commands are considered “non-data-entry”.

Name        Percentage of non-data-entry commands
Rick            83%
Xah Lee         63%
Marc Shapiro    26%

A higher percentage of non-data-entry commands probably means that the person is doing a lot editing, as opposed to writing. (if a person uses emacs for email or IRC chat, she's likely to have high percentage of data-entry commands.)

Commands that are executed by the same key are grouped together. For example, the commands “delete-backward-char”, “backward-delete-char-untabify”, “python-backspace”, “cperl-electric-backspace” are all just the “Backspace” key.

The following is the complete list of commands that are merged.

command names                 merged into this glyph
next-line                     ↓
dired-next-line               ↓
next-history-element          ↓
previous-line                 ↑
dired-previous-line           ↑
previous-history-element      ↑
delete-backward-char          ⌫
backward-delete-char-untabify ⌫
python-backspace              ⌫
cperl-electric-backspace      ⌫

scroll-up                     ▼
cua-scroll-up                 ▼

scroll-down                   ▲
cua-scroll-down               ▲

isearch-forward                isearch-→
isearch-repeat-forward         isearch-→

isearch-backward               isearch-←
isearch-repeat-backward        isearch-←

For clarity, some commands are replaced by a glyph. Here's the complete list:

backward-char           ←
forward-char            →
backward-word           ←w
forward-word            →w
backward-sentence       ←s
forward-sentence        →s
backward-paragraph       ↑¶
forward-paragraph        ↓¶

move-beginning-of-line  |←
move-end-of-line         →|
beginning-of-buffer     |◀
end-of-buffer           ▶|

delete-char            ⌦
kill-word              ⌦w
backward-kill-word     ⌫w
kill-line              ⌦l
kill-sentence          ⌦s
kill-ring-save         copy
kill-region            ✂

Command Frequency Table

Total number of command calls: 203118

Percent of non-data-entry command calls: 67%

←w 67823.34
nonincremental-repeat-search-forward 41412.04
back-to-indentation-or-beginning 32731.61
isearch-printing-char 26821.32
end-of-code-or-line 24791.22
cua-delete-region 23091.14
yank 16910.83
indent-relative 13330.66
save-buffer 13020.64
just-one-space 12950.64
newline 11850.58
handle-switch-frame 11170.55
(lambda nil (interactive) (scroll-up 1)) 10950.54
rgb-doublespace-maybe 9720.48
search-backward 9320.46
execute-extended-command 9000.44
universal-argument-other-key 8910.44
cua-copy-region 8020.39
mouse-drag-region 7460.37
kill-buffer-silently 7400.36
digit-argument 7310.36
nonincremental-search-forward 7210.35
isearch-→ 6940.34
cua-resize-rectangle-right 6740.33
other-window 6720.33
cua-resize-rectangle-down 6360.31
undo 6240.31
|◀ 5460.27
mouse-set-point 5310.26
jump-to-register 4880.24
point-to-register 4810.24
(lambda nil (interactive) (scroll-down 1)) 4100.20
facemenu-set-bold 4010.20
nonincremental-repeat-search-backward 3970.20
minibuffer-complete 3700.18
|← 3590.18
set-mark-command 3510.17
→| 3480.17
insert-prior-line-char 3380.17
▶| 3360.17
isearch-other-control-char 3240.16
dired 3200.16
newline-and-indent 3160.16
dired-advertised-find-file 3080.15
isearch-other-meta-char 2950.15
next-file-buffer 2870.14
find-file 2650.13
kill-buffer 2330.11
cua-move-rectangle-right 2280.11
fill-paragraph 2250.11
isearch-← 2210.11
(lambda nil (interactive) (mark-sexp -1 t)) 2180.11
revert-buffer 1880.09
universal-argument 1820.09
exit-minibuffer 1760.09
copy 1740.09
cua-resize-rectangle-up 1740.09
search-word-under-cursor 1650.08
recenter 1640.08
cua-insert-char-rectangle 1620.08
ediff-next-difference 1520.07
scroll-bar-toolkit-scroll 1480.07
kill-this-buffer 1470.07
delete-other-windows 1450.07
extend-selection 1440.07
eval-last-sexp 1410.07

How The Report Is Compiled

Here we describe how the report is generated. Each person, uses this emacs code: command-frequency.el, which will accumulate a keyed-list of all command the user calls in emacs, with key being the command name and value being its count. After some time, the user calls command-frequency-display which will write the stat into a buffer, then the user save it to file.

The raw data files used in this report are here: command-frequency_old.tgz

A Python program command-frequency_v1.1.py, is used to parse these raw data files. The program aggregate all user's raw data, then groups some commands together as described in this report, and replace some command names by a corresponding glyph, and print them in HTML table format. Commands used less than 0.1% of total non-data-entry commands are not displayed.

When this report is written, the command logging program “command-frequency.el” used “this-command” variable to record what command is being called. The “this-command” lumps together backward-kill-word, kill-word, kill-line, kill-region, all into just kill-region. (see: (info "(elisp) Command Loop Info")) This problem is fixed in the current version of the “command-frequency.el”. (it now uses real-last-command variable to log commands)

Subsequent stat using Xah Lee's stat shows that, the lumped kill commands have this frequentcy distribution:


The above distribution is retrofitted into the report.

If you like to participate in this research, please download command-frequency.el and send me the output. I will incorporate your data into the next report update. Thank you.

Thanks to Ryan Yeske for the inital version of command-frequency.el. Thanks to Michal Nazarewicz writing it into a full featured minor mode. Thanks to David Capello for improving the code. Thanks to Katsumi Yamaoka for pointing out the problem of “this-command”. Thanks to Stefan Guath for pointing out “real-last-command”. Thanks to Marc Shapiro and Rick Bielawski for providing me their data.

Addendum: My own (Xah Lee) command usage stat for 5 months: command-frequency_xah.txt.

Liket it? Put $1 at patreon. Or Buy Xah Emacs Tutorial. Thanks.