vim-keypress-analyzer
parses vim keypress log files generated by
(n)vim -w <a_log_file>
and aggregates key press counts and some antipattern analysis.
Note: this is not delivering accurate numbers yet, check TODOs
$ vim-keypress-analyzer --file ~/.nvim_keylog --limit 10 --enable-antipatterns
Vim Keypress Analyzer
Key presses per mode (total: 104281)
│─────────────────│───────│───────────│
│ IDENTIFIER (4) │ COUNT │ SHARE (%) │
│─────────────────│───────│───────────│
│ insert │ 46.2K │ 44.32 │
│ normal │ 43.7K │ 41.98 │
│ command │ 7.4K │ 7.11 │
│ visual │ 6.8K │ 6.58 │
│─────────────────│───────│───────────│
Key presses excluding [insert, command] modes (total: 50642)
│──────────────────│───────│───────────│
│ IDENTIFIER (10) │ COUNT │ SHARE (%) │
│──────────────────│───────│───────────│
│ w │ 7.9K │ 14.01 │
│ <space> │ 4.3K │ 8.51 │
│ j │ 3.4K │ 6.78 │
│ k │ 2.9K │ 5.91 │
│ b │ 2.4K │ 4.83 │
│ d │ 1.5K │ 3.15 │
│ e │ 1.4K │ 2.93 │
│ i │ 1.3K │ 2.62 │
│ l │ 1.2K │ 2.54 │
│ <esc> │ 1.2K │ 2.45 │
│──────────────────│───────│───────────│
Found Antipatterns
│───────────────│───────│───────────────────│─────────────────────────│
│ PATTERN (16) │ COUNT │ TOTAL KEY PRESSES │ AVG KEYS PER OCCURRENCE │
│───────────────│───────│───────────────────│─────────────────────────│
│ www+ │ 559 │ 3.6K │ 5.48 │
│ bbb+ │ 306 │ 1.5K │ 4.97 │
│ ko │ 195 │ 390 │ 2.00 │
│ jjj+ │ 148 │ 777 │ 5.25 │
│ li │ 145 │ 290 │ 2.00 │
│ kkk+ │ 140 │ 794 │ 5.67 │
│ eee+ │ 126 │ 734 │ 5.83 │
│ jO │ 52 │ 104 │ 2.00 │
│ lll+ │ 37 │ 398 │ 10.76 │
│ xxx+ │ 31 │ 131 │ 4.23 │
│ hhh+ │ 28 │ 137 │ 4.89 │
│ dddd+ │ 23 │ 102 │ 4.43 │
│ ha │ 7 │ 14 │ 2.00 │
│ WWW+ │ 2 │ 12 │ 6.00 │
│ BBB+ │ 2 │ 6 │ 3.00 │
│ XXX+ │ 1 │ 6 │ 6.00 │
│───────────────│───────│───────────────────│─────────────────────────│
- count total keys pressed by mode (NORMAL, INSERT, VISUAL, COMMAND)
- count key presses for each key (excludable modes, e.g. don't show
insert
mode key presses) - detect repetitive key sequences as antipatterns (e.g.
jjj
ordddd
)- detect repetitive multi key sequences like
dwdwdwdw
- detect repetitive multi key sequences like
- Download the archive for your OS (OSX and Linux, OSX is not tested yet) from the releases page
- Extract the binary
vim-keypress-analyzer
to a directory in your$PATH
- start vim with the
-w <path/to/logfile>
flag (see:h -w
) to tracking your key presses - edit files/text
- quit vim. This will create or append the
<path/to/logfile>
with the keys you have pressed in the session
Helpful alias to always log your keys:
alias n='nvim -w ~/.nvim_keylog "$@"'
# or
alias v='vim -w ~/.vim_keylog "$@"'
If you want to split the logs per day, to track progress for example:
# necessary once
mkdir ~/.vim_logs
# automatically write to ~/.vim_logs/YYYY-MM-DD.log
alias n='nvim -w ~/.vim_logs/$(date -Idate).log "$@"'
# or
alias v='vim -w ~/.vim_logs/$(date -Idate).log "$@"'
There is only a single mandatory option: -f
`--file` to the log file generated in the previous step.
$ vim-keypress-analyzer -f <a_log_file>
Flag | Description | Possible values | Default |
---|---|---|---|
-l , --limit |
limit the number of key presses displayed | any positive int | 0 (unlimited) |
-a , --enable-antipatterns |
boolean flag, enable a rudimentary antipattern analysis | flag is present or not | false |
-e , --exclude-modes |
comma separated list of modes to be excluded from the key press list | insert,normal,command,visual | insert,command |
- be able to see the ratio of typing in
insert
mode vs. other modes- if you are typing 99.9% of the time in
insert
mode, there is not much reason to use vim
- if you are typing 99.9% of the time in
- count the characters you type in vim (e.g. per day)
- identify your most pressed keys in non-insert modes, to check for example for optimization potential
- identify antipatterns in your editing habit. Antipatterns means repetitive or inefficient key strokes.
For example, pressing eight times
j
repetitively is considered an antipattern. Similarly, pressingA<cr>
can be done as well byo
- improve motion detection - e.g.
ciw
- command & insert mode shares seem to high - check
- rewrite antipattern detection [WIP]
- configurable via yaml file
- option to store results in a structured format (json e.g.)
- (maybe)
<leader><key>
detection? - the numbers are otherwise not 100% correct - (maybe maybe) build a vim plugin that logs keys on the fly to a structured log format