Skip to content

holyprin/keymap-utils.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

keymap-utils.nvim

A lightweight Neovim utility for ergonomic keymap definitions.

Installation

vim.pack (Neovim 0.12+)

vim.pack.add('holyprin/keymap-utils.nvim')

lazy.nvim

{ 'holyprin/keymap-utils.nvim' }

mini.deps

MiniDeps.add('holyprin/keymap-utils.nvim')

Usage

local map = require('keymap-utils').map

API

map.<modes>(lhs, rhs, [desc], [opts])

Sets a keymap for one or more modes. The mode is specified by chaining mode characters directly onto map.

Parameter Type Description
lhs string The key sequence to map
rhs string|function The action to perform
desc string (optional) Human-readable description, shown in which-key etc.
opts table (optional) Extra options passed to vim.keymap.set

Keymaps are created with noremap = true and silent = true by default.

Modes

Any combination of standard Neovim mode characters can be used:

Character Mode
n Normal
i Insert
v Visual
x Visual block
s Select
t Terminal
o Operator-pending
c Command

Examples

local map = require('keymap-utils').map

-- Single mode
map.n('<leader>w', ':w<CR>', 'Save file')
map.i('jk', '<Esc>')

-- Multiple modes
map.ni('<C-s>', ':w<CR>', 'Save file')
map.nv('<leader>y', '"+y', 'Yank to clipboard')
map.nix('<C-c>', '<Esc>', 'Escape')

-- With a function
map.n('j', function()
    return vim.v.count == 0 and 'gj' or 'j'
end, 'Move down (wrap-aware)', { expr = true })

-- Extra options
map.n('<leader>p', '"_dP', 'Paste without yanking', { nowait = true })

About

Small keymap utility plugin for managing neovim keybinds

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages