VIM: know which command is executed when a key is pressed

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

+4
source share
2 answers

To view the mappings, use:

 :verbose map <leader>c 

If necessary, replace the card with the appropriate imap, cmap, etc.

For Vim built-in commands, you will need help:

 :help gq 

See :help context for pointers.

+10
source

Sometimes, if map <keys> not enough, you can use one of the following values:

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

These are all advanced debugging features, and they are very time consuming, but they can help when something simpler cannot.

+2
source

Source: https://habr.com/ru/post/1346416/


All Articles