HomePostsNeovim Plugin: Which Key

Neovim Plugin: Which Key

Mar 4, 2024
1 minutes read

Vim/Neovim is a keyboard-driven IDE, which means you can code efficiently without needing to switch between your keyboard and your mouse. This is where key bindings become invaluable, significantly enhancing productivity.

However, remembering the vast array of default and custom key bindings can be challenging. This is where WhichKey steps in, offering a visual guide to all possible key bindings for the command you started typing.

Let's install WhichKey into your Neovim. I prefer using lazy.nvim as my NeoVim's package manager, but feel free to use your your prefered package manager.

{
    "folke/which-key.nvim",
    event = "VeryLazy",
    init = function()
        vim.o.timeout = true
        vim.o.timeoutlen = 300
    end,
    opts = {
        -- your configuration comes here
        -- or leave it empty to use the default settings
        -- refer to the configuration section below
    }
}

You can start using WhichKey with the default configuration (full configuration can be found here). Simply press your first key, and if there are any associated key bindings, WhichKey will display a popup listing them, prefixed by your initial key.

For instance, if I press g, WhichKey will show a list of key bindings starting with g, as the screenshot below:

Figure 1