← Back home

Yanky: I can't believe this isn't default in nvim...

Published on April 16, 2025

I'm a proud and open neovim user. However, I have found one annoyance: yanking the second last line in vim is not possible.

You can store a yanked item in regsiter intentionally like "2y (stores it in regsiter 2). You can also paste the second last DELETED line (1-9 registers contain deleted lines in order), but there is nothing for yank.

To fix this, I installed yanky and have it set up such that both yanks and deletes share the same registers. This solves most of my problems, as if I paste something from the web browser, my last yanks is removed, and it is very annoying

Config setup:

return {
  "gbprod/yanky.nvim",
  opts = {
    ring = {
      history_length = 100,
      storage = "shada",
      sync_with_numbered_registers = true,
    },
    highlight = {
      on_put = true,
      on_yank = true,
      timer = 200,
    },
  },
  keys = {
    -- Yank/Put Commands
    { "p", "(YankyPutAfter)", mode = "n", desc = "Yanky Put After" },
    { "P", "(YankyPutBefore)", mode = "n", desc = "Yanky Put Before" },
    -- Cycle through yank history
    { "", "(YankyCycleForward)", desc = "Yank Cycle Forward" },
    { "", "(YankyCycleBackward)", desc = "Yank Cycle Backward" },
  },
}
      

So now instead of my :registers looking like this:

0: [Last yanked item]
1: [Last deleted item]
2: [Second last deleted item]
3: [Third last deleted item]
4: [Fourth last deleted item]
      

It looks like this

1: [Last yanked item]
2: [Second last yanked item]
3: [Last deleted item]
4. [Third last yanked item]
5. [Second last deleted item]
      

and