Emacs's Command Frequency Statistics

Buy Xah Emacs Tutorial. Master emacs benefits for life.
, , …,

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

In emacs, each key press invokes a command. For example, pressing a 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. Scrolling the mouse wheel invokes the command mwheel-scroll.

The motivation of this study, is in designing a Ergonomic Keybinding. I needed to know what commands are more frequently used, in order to give it a easier-to-press key.

Preliminary

Contributors

This report's data are from the following people:

Percentage of Each Person's Data Contribution
NamePercentageNumber of Command Call
Alan Mackenzie03170
Marc Shapiro127259
Rick Bielawski4166178
David Capello18817127
Trey Jackson371736697
Xah Lee411911332

Total number of command calls: 4661763.

Data Entry Commands vs Non Data Entry Commands

For this report, we consider each emacs command belongs to one of 2 categories: “data entry” and “none data entry”.

“data entry” commands are commands that are typing, such as pressing any of letter keys, number keys, or Enter ↵ key. Emacs command name for these are: {self-insert-command, newline, org-self-insert-command, isearch-printing-char, org-return, …}.

All other commands are considered “none data entry”.

This division is important for our study because commands that insert characters do not need a keyboard shortcut, they already correspond to each key on the keyboard. But also, we can tell what percentage keystroke in emacs is spend on typing.

Percentage of Data Entry for Each Contributor
NamePercentage of Data Entry Commands
Rick Bielawski19
David Capello35
Xah Lee50
Alan Mackenzie54
Trey Jackson54
Marc Shapiro75

Average: 48%

A higher percentage of data entry probably indicates that the person is doing a lot tasks that are mostly continuous fast typing, such as writing email, study notes, diary, irc chat.

Command Groups

Commands that are executed by the same shortcut 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, and or represented by a glyph for clarity of reading.

Merged Commands
Emacs Command NameMerged Name or Glyph
self-insert-commandinsert char
org-self-insert-commandinsert char
isearch-printing-charinsert char
newline
org-return
org-return-indent
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
org-delete-backward-char
cua-scroll-up
scroll-up
scroll-down
cua-scroll-down
isearch-forwardisearch-→
isearch-repeat-forwardisearch-→
isearch-backwardisearch-←
isearch-repeat-backwardisearch-←
backward-char
forward-char
backward-word←w
forward-word→w
backward-sentence←s
forward-sentence→s
backward-paragraph↑¶
forward-paragraph↓¶
org-beginning-of-line|←
move-beginning-of-line|←
move-end-of-line→|
org-end-of-line→|
beginning-of-buffer|◀
end-of-buffer▶|
delete-char
org-delete-char
cua-delete-region
kill-word⌦w
backward-kill-word⌫w
kill-line⌦l
org-kill-line⌦l
kill-sentence⌦s
kill-ring-savecopy
cua-copy-regioncopy
yankpaste
cua-pastepaste
kill-region
cua-cut-region
set-markset mark
cua-set-markset mark

Command Frequency Table

Total number of command calls: 4661763

Total number of data entry command calls: 2234669

Percent of data entry command calls: 48%

Emacs Command List by Frequency of Use
Command NameCount% of Total% of None Data Entry
0insert char218232046.81N/A
14150048.9017.10
23756008.0615.48
3 →w1502243.226.19
41250172.685.15
5 ←w1140452.454.70
6784651.683.23
7756571.623.12
8isearch-→644771.382.66
9523491.122.16
10 |←436840.941.80
11 ⌫w406840.871.68
12paste329720.711.36
13save-buffer313100.671.29
14 ⌦l285690.611.18
15263890.571.09
16211730.450.87
17minibuffer-complete193360.410.80
18other-window192560.410.79
19 →|190040.410.78
20find-file180210.390.74
21scroll-up-1175280.380.72
22handle-switch-frame173270.370.71
23isearch-other-meta-char172760.370.71
24comint-send-input170320.370.70
25forward-sexp160450.340.66
26execute-extended-command159960.340.66
27close-current-buffer157880.340.65
28154080.330.63
29set mark152810.330.63
30 ⌦w150170.320.62
31isearch-←127170.270.52
32c-forward-subword126450.270.52
33undo122960.260.51
34move-cursor-next-pane121830.260.50
35copy119490.260.49
36switch-to-buffer119410.260.49
37forward-block117590.250.48
38shrink-whitespaces113550.240.47
39106800.230.44
40isearch-other-control-char102130.220.42
41comint-previous-input100580.220.41
42 ↓¶ 96690.210.40
43 |◀ 87640.190.36
44backward-block 82430.180.34
45 ▶| 80010.170.33
46dired-advertised-find-file 78030.170.32
47scroll-down-1 77330.170.32
48backward-sexp 74760.160.31
49delete-other-windows 69680.150.29
50set-mark-command 64060.140.26
51next-error 62350.130.26
52 ↑¶ 61100.130.25
53switch-to-next-frame 55130.120.23
54isearch-yank-word-or-char 55080.120.23
55yas/expand 49210.110.20
56mark-sexp 48060.100.20
57tj-newline-and-indent-command 46950.100.19
58iswitchb-buffer 46580.100.19
59nonincremental-repeat-search-forward 44740.100.18
60extend-selection 44240.090.18
61c-backward-subword 44200.090.18
62minibuffer-keyboard-quit 43550.090.18
63exit-minibuffer 42950.090.18
64revert-buffer 42050.090.17
65tcl-electric-char 41620.090.17
66iswitchb-exit-minibuffer 41020.090.17
67split-window-vertically 40350.090.17
68search-forward-regexp 40210.090.17
69jabber-chat-buffer-send 38330.080.16
70kill-buffer 37310.080.15
71rgb-doublespace-maybe 36910.080.15
72scroll-down-2 34480.070.14
73comint-beginning-of-line 33650.070.14
74back-to-indentation-or-beginning 32730.070.13
75select-text-in-quote 32500.070.13
76toggle-letter-case 32350.070.13
77c-electric-star 32260.070.13
78c-electric-backspace 31960.070.13
79scroll-bar-toolkit-scroll 29410.060.12
80scroll-up-2 29230.060.12
81c-indent-line-or-region 28860.060.12
82c-backward-kill-subword 28460.060.12
83abort-recursive-edit 28320.060.12
84beginning-of-visual-line 28280.060.12
85recenter 27790.060.11
86gnus-summary-next-unread-article 27720.060.11
87isearch-exit 27300.060.11
88gnus-topic-read-group 27180.060.11
89exchange-point-and-mark 26900.060.11
90ignore 26270.060.11
91gnus-group-get-new-news 25190.050.10
92insert-tag 24860.050.10
93cua-cancel 24800.050.10
94end-of-code-or-line 24790.050.10
95c-electric-slash 24400.050.10

Interesting Highlights

Some interesting highlights from the stat, organized by common editing operations.

GlyphCommand Name%
previous-line15.48
next-line17.10
backward-char3.23
←wbackward-word4.70
←¶backward-paragraph0.25
|←move-beginning-of-line1.80
forward-char5.51
→wforward-word6.19
→¶forward-paragraph0.40
→|move-end-of-line0.78
scroll-down (page up)0.63
scroll-up (page down)1.09
|◀beginning-of-buffer0.36
▶|end-of-buffer0.33
delete-backward-char3.12
⌫wbackward-kill-word1.68
|⌫kill-line-backward0.00
delete-char0.87
⌦wkill-word0.62
⌦|kill-line1.18
copykill-ring-save0.49
cutkill-region0.44
pasteyank1.36
paste previousyank-pop0.00
set-markset-mark0.63
undoundo0.51
M-xexecute-extended-command0.66
Openfind-file, dired-advertised-find-file(0.74+0.32)/2
Closekill-buffer, close-current-buffer(0.15+0.65)/2
Savesave-buffer1.29
Save Aswrite-file0.00

† Percentage with Respect to Non Data Entry Commands Count

How the Report is Compiled

Here we describe how the report is generated. Each person, installs this emacs package: command-frequency.el. (A new version, by David Capello, renamed as keyfreq.el, is available at https://github.com/dacap/keyfreq. You should use this new version. )

The package will accumulate a key/value list of all commands the user calls in emacs. The key is command name and the value is the number of times that command has been called. After some time, the user calls “command-frequency-display”. This 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_data_files.tgz

A Python program command-frequency.py, is used to parse these raw data files. The program aggregate all user's raw data, discard some commands such as mwheel-scroll, “nil”, keyboard macros, etc, then groups some commands together as described in this report, and replace some command names by a corresponding glyph, then computes the various statistics used for this report, and print them in HTML. Commands used less than 0.1% of total none data entry commands are not reported

Currently, this report is not normalized. For example Xah Lee (me)'s data is 41% of the whole. So, that means my usage pattern has major influence. You can use the Python program to select which file or group of files to use for generating the stat. The overall pattern does not change much. For comparison, see this version of report without Xah Lee (me)'s data, see: Emacs's Command Frequency Sans XL. For the previous version of this report, made in 2007 with much less data, see: Emacs's Command Frequency (Old).

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.

Files people have sent to me for report but i haven't had time to process:

, addendum: i didn't have time to work on this. This project needs to be automated. The keyfreq.el package should automatically send user's results to a server (such as github, and with user's consent in a preference), and automatically generate statistics. If you are interested, get in contact with David Capello, the author of keyfreq.el, or, you can join the ergoemacs-mode developement at https://ergoemacs.github.io/, led by Matthew Fidler.

Acknowledgment

Ryan Yeske hacked up a quick elisp code that count commands for the current session. Michal Nazarewicz made it into a full featured minor mode, with the ability to read and write to a file to accumulate log across sessions, and print percentages in report. David Capello added a feature to also log the mode the command is from.

Thanks to Katsumi Yamaoka for pointing out the problem of “this-command”. Thanks to Stefan Guath for pointing out “real-last-command”. Thanks to all the people who provided me their data.

Like it?
Buy Xah Emacs Tutorial
or share
blog comments powered by Disqus