Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to view the currently mapped keys in Vim?

Tags:

vim

People also ask

How do you check if a key is mapped in vim?

Use :map! and :map for manually set keys and :help 'char(-combination)' to find out which keys are already mapped in vim out-of-the-box(/out of your specific compiling options).

How do I map a key in vim?

Creating keymaps To map a sequence of keys to execute another sequence of keys, use the ':map' command. For example, the following command maps the <F2> key to display the current date and time. The ':map' command creates a key map that works in normal, visual, select and operator pending modes. The ':map!'

What is the silent key in vim?

<silent> tells vim to show no message when this key sequence is used. <leader> means the key sequence starts with the character assigned to variable mapleader -- a backslash, if no let mapleader = statement has executed yet at the point nmap executes.


You can do that with the :map command. There are also other variants.

  • :nmap for normal mode mappings
  • :vmap for visual mode mappings
  • :imap for insert mode mappings

The above list is not complete. Typing :help map in Vim will give you more info.


:redir! > vim_keys.txt
:silent verbose map
:redir END

This outputs the shortcuts, with where they were defined, to a text file.


In addition to answers about :map with no arguments: do not miss its verbose form (:verbose map) which shows where the mapping(s) was defined (see :help map-verbose).


Quite simply, just run the :map variants with no arguments.

:map
:imap
:vmap

:map and its friends are the key, :verbose adds info and :redir allow post-search refinement.

They are a perfect mix to show what command is bind to what shortcut and viceversa, but if you want to search some keys and avoid temp files whenever you need to search mappings, take a look to scriptease and :Verbose command.

It is a wrapper on :verbose to show result in a preview window.

this way you can search whatever you want inside results without using temp files

type :Verbose map and use / ? as usual.


Another way is to save session to a file and then edit this file as it contains all the mappings and settings.

:mks[ession] [file] - Write a Vim script that restores the current editing session.