Skip to main content

Using which-key in LazyVim

LazyVim uses the which-key.nvim plugin extensively to make its massive list of keymaps discoverable. If you ever forget a keymap, which-key is your built-in interactive cheat sheet.

What which-key does and why it matters​

which-key.nvim displays a popup with possible key bindings of the command you started typing. It helps you remember shortcuts and explore what your editor can do without having to look up external documentation or dig through configuration files.

Triggering which-key​

To see the available keymaps, simply press <Space> (your default leader key) and wait a moment. A popup will appear at the bottom of your screen showing all the available next key presses.

You can also trigger it for other prefixes. For example, press g or [ and wait to see all commands starting with those keys.

Reading the popup​

The popup organizes keymaps into groups (e.g., +git, +search, +buffer).

  • A yellow label indicates a group of further keys.
  • A blue label indicates an executable action.

If you press a key corresponding to a group (e.g., g for Git), which-key will update the popup to show the actions available under that group (e.g., g for lazygit, b for blame).

Adding your own keymaps with descriptions​

When adding custom keymaps in lua/config/keymaps.lua, you can provide a desc field. which-key will automatically pick this up and display it!

vim.keymap.set("n", "<leader>my", "<cmd>echo 'Hello'<CR>", { desc = "My Custom Action" })

Customizing which-key appearance​

If you want to change how which-key looks (e.g., remove the background, change the delay), you can override its options in lua/plugins/which-key.lua:

return {
"folke/which-key.nvim",
opts = {
delay = 200, -- Delay before the popup shows up (in milliseconds)
preset = "modern",
},
}