Phương Nguyễn
Phương Nguyễn

Reputation: 8905

VIM: Know which command executed when a key pressed

How do I know which command will be executed when I press a key, for example <Leader>c?

Upvotes: 7

Views: 2206

Answers (2)

ZyX
ZyX

Reputation: 53674

Sometimes if map <keys> is not enough you may use one of the following:

  • :debug normal <keys><CR>: for normal, visual, select, operator-pending and insert/replace/virtual replace modes but not for ex/command-line mode. You will have to precede <keys> with something that enters target mode.
  • :set verbosefile=/tmp/verbose.log verbose=15<CR><keys>:set verbose=0<CR>: for all modes it will procude a log of all commands executed in file /tmp/verbose.log. You will see errors if there is a recursive structure somewhere.
  • Start vim with vim -s <(echo '<keys>') -D. It will enter debug mode immediately after vim starts, but you will have to skip all initializations manually.

These are all advanced debugging features and they are very time-consuming, but they may help where something more simple cannot.

Upvotes: 4

Raimondi
Raimondi

Reputation: 5303

To see mappings use:

:verbose map <leader>c

Replace map by the corresponding imap, cmap, etc., as needed.

For Vim's built-in commands you'll need to use the help:

:help gq

See :help context for pointers.

Upvotes: 15

Related Questions