Add A Neovim Keymap To A Single Buffer
April 2025
Just This One
You can confine a hotkey/keymap to a single buffer with:
local buffer_number = 0
vim.keymap.set("n", "q", function()
print("caught 'q' on target buffer")
end,
{ buffer = buffer_number }
)In this case, the buffer_number is set to 0 which is the current buffer. It can be set to any desired buffer.
end of line