Neovim Hilight On Yank

Published on Aug. 14, 2022 | Tags: neovim dev-tools TIL

I learned something today that has been in neovim for a while, now. On yank, it's possible to make the yanked text blink for a certain amount of time.


vim.api.nvim_create_autocmd("TextYankPost", {
group = vim.api.nvim_create_augroup("ConfigGroup", { clear = true }),
pattern = "*",
command = "lua vim.highlight.on_yank({ higroup = 'IncSearch', timeout = 250 })",
})

And you can customize the colour of the highlight through the higroup argument.


Edit: Also, now you can create autocmd's with the Lua API which is kind of neat.


Ref.: https://stackoverflow.com/questions/26069278/highlight-copied-area-in-vim


Ferran Jovell