Xah Lee, 2007-07
In emacs, each key press actually invokes a command. (For example, typing “a” actually invokes the command “self-insert-command”. Typing Ctrl+f invokes the command forward-char. Typing Alt+x invokes execute-extended-command.)
This page lists the order of commands used in emacs by their frequency of use.
The following frequency list is based on a single user (me) for about 6 day's use of emacs in 2006-10, with 82952 command calls.
Because it is based on a single user, the frequency order is biased towards the user's editing tasks and habits. However, it can give a rough indication on which commands are more frequently used. For example, is backward-char more frequently used than yank (paste)? is Undo more frequently used than move-beginning-of-line?
Commands that involves moving the cursor, are colored red. Commands that modifies text or related to editing (such as set-mark-command, kill-ring-save (copy), yank (paste), delete-word), are colored blue. Commands that results from the same keystroke are grouped together (For example, delete-backward-char, backward-delete-char-untabify, python-backspace, cperl-electric-backspace are all grouped together because they are all just the Backspace key. Another example: the commands next-line, dired-next-line, next-history-element are all grouped together because they have the same semantics of the down-arrow key.
100% total number of command calls = 82952.
37.05% data entry commands (keystrokes)
29758 self-insert-command
978 newline
30736 (total)
62.95% non-data-entry command calls = 52216.
In the following, the percentage values are percentage with respect to total number of non-data-entry command calls. For example, backward-word is called 4699 times. So, 4699/52216 = 8.999%.
20.193% ↓ (commands having semantics of down arrow)
10149 next-line
380 dired-next-line
15 next-history-element
10544
16.221% ↑ (commands having semantics of up arrow)
7912 previous-line
168 dired-previous-line
390 previous-history-element
8470
8.999% backward-word
4699
7.089% forward-word
3702
5.176% kill-region
2703
4.969% Backspace key
1754 delete-backward-char
771 backward-delete-char-untabify (emacs-lisp)
53 python-backspace
17 cperl-electric-backspace
2595
3.740% → forward-char
1953
2.922% ← backward-char
1526
2.449% 1279 save-buffer
1.593% 832 yank
1.417% 740 kill-buffer-silently (custome kill-buffer)
1.173% page down
613 scroll-up
1.137% isearch-forward and isearch-repeat-forward
455 isearch-forward
139 isearch-repeat-forward
594
What follows are below 1%.
412 undo 412 other-window 373 delete-char 344 scroll-down 301 minibuffer-complete 290 execute-extended-command 288 set-mark-command 283 dired 251 move-beginning-of-line 241 dired-advertised-find-file 210 find-file 114 isearch-backward 91 isearch-repeat-backward 2492 isearch-printing-char 285 isearch-other-meta-char 271 isearch-other-control-char 16 isearch-abort 183 beginning-of-buffer 170 revert-buffer 164 move-end-of-line 159 recenter 153 kill-ring-save 144 extend-selection * 136 delete-other-windows 131 eval-last-sexp 126 end-of-buffer 122 mouse-drag-region 117 split-window-vertically 114 minibuffer-keyboard-quit 96 keyboard-quit 104 ibuffer-mark-for-delete 102 fill-paragraph 98 mouse-set-point 91 exit-minibuffer 88 shell-command 83 just-one-space 79 describe-function 74 describe-key 72 lisp-indent-line 3 indent-for-tab-command , dired python ...
Based on the list, with consideration of assigning keyboard shortcuts to the most frequently used commands, we can group the most frequently used commands into 3 categories: (1) Commands that moves the cursor. (2) Commands that changes text (such as copy, paste, delete-backward-char, backward-kill-word). (3) Other.
In the following, we look at the primary cursor moving commands provided by emacs (such as moving to beginning/ending of char, word, line, sentence, paragraph, screenful, file), and place their frequency of use aside the command, for ease of comparison of what moving commands are used how often. Then, we do a similar layout on commands that does text editing (copy, paste, kill-word, kill-line,...).
Moving cursor by char, word, line, sentence, paragraph, screenfull, or beginning/ending of a file. (the glyphs at the left are provided for visual clarity).
↑ 16.221% previous-line ↓ 20.193% next-line ← 2.922% backward-char → 3.740% forward-char ←w 8.999% backward-word →w 7.089% forward-word |← 0.0480% move-beginning-of-line →| 0.0314% move-end-of-line ←s 0% backward-sentence →s 0% forward-sentence ←¶ 0% backward-paragraph →¶ 0% forward-paragraph ▲ 0.658% scroll-down (page up) ▼ 1.173% scroll-up (page down) |◀ 0.350% beginning-of-buffer ▶| 0.241% end-of-buffer
Other:
recenter 0.304% move-to-window-line, M-r 0% tab-to-tab-stop, M-i 0% back-to-indentation, M-m 0%
Single Character Deletion invoked by the Backspace key or (forward) Delete key, or emacs's shortcut Ctrl-d.
backward delete (backspace key) 4.969% forward delete (delete-char) 0.714%
Deletion by word, line, paragraph
? backward-kill-word ? kill-word ? kill-line 0 backward-kill-paragraph 0 kill-paragraph
For technical reasons, the program that compiled the frequency list, lumps commands backward-kill-word, kill-word, kill-line, kill-region, all into just kill-region.
Mark, Copy, Cut, Paste
set-mark-command 0.551%
kill-ring-save 0.293%
kill-region 5.176%
(includes: backward-kill-word, kill-word, kill-line)
yank 1.593%
yank-pop 0.003%
mark-whole-buffer 0.114%
Undo.
undo 0.789%
Other.
102 fill-paragraph 0.195% 32 query-replace 22 query-replace-regexp 18 string-rectangle 12 replace-string 7 downcase-word, M-l 5 upcase-word 6 upcase-initials-region 0 translate-region 0 transpose-chars 0 transpose-words 0 transpose-lines 0 transpose-paragraphs 0 transpose-regions 0 transpose-sentences 0 transpose-sexps 0 transpose-subr 0 transpose-subr-1 0 comment-dwim, M-; 0 indent-new-comment-line, M-j 0 zap-to-char, M-z 0 tags-loop-continue, M-, 0 find-tag, M-. 0 dabbrev-expand, M-/
The above frequency list is a edited version of the output by the elisp program that counts invoked commands.
The editing are done as follows: Commands called less than 70 times are removed. (these are less than 0.13% of total non-data-entry command calls (70/52216 = 0.13%). Customized Commands that are not related to general emacs use are also deleted. (for example, insert-p inserts a specialized HTML markup, “,bbedit” opens the current buffer in a Mac text editor or Finder). Customized command that are related to general emacs use, or as a substitute to other emacs commands, are NOT removed. For example, i have defined kill-buffer-silently, which is similar to kill-buffer except that it does not prompt unless the file is not saved. Uninteresting commands in this context, such as mwheel-scroll, nil (probably due to canceled command or error), ignore, are removed.
The complete, unedited raw output is here: command-frequency_xah.txt.
The program that counts the command is here: command-frequency.el. Once you run the program, each command you use in emacs is counted. When you want, type Alt+x command-frequency-display to list the commands you have used, and the number of times they are called. (if you compile your own statistics, please email to me and i'll incorporate the result into this report.)
See also:
