Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM: Know which command executed when a key pressed

Tags:

vim

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

like image 784
Phương Nguyễn Avatar asked Apr 03 '11 07:04

Phương Nguyễn


2 Answers

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.

like image 112
Raimondi Avatar answered Nov 03 '22 08:11

Raimondi


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.

like image 3
ZyX Avatar answered Nov 03 '22 09:11

ZyX