Pressing `cut` key quickly after visual selection doesn't place in register
Hello!
I posted on the vim StackExchange and unfortunately didn't really get much help beyond "make an issue in the plugin repo," so apologies if this ends up not being an issue with this plugin specifically. I was unable to get any more info about a potential underlying issue/limitation with the approach this and similar vim plugins take.
A common thing I run into is that I want to cut a line and want to hold it in a register while I move around and delete other things. What I usually do is V and then x (assigned as the cut key in my config). I then do whatever other deleting with d and then eventually go to p the content I cut. Depending on how quickly I press x after V, it may not actually overwrite what was previously in the register.
https://github.com/user-attachments/assets/1be0afa8-b6f6-435b-b536-6a4688c623b5
In this example, I'm first yanking the plugin name. I paste it just to show it's in the register. Then I cut a few other lines quickly and paste. You can see that it uses the initial line that I yanked. The last part is me pausing after the visual selecting and then cutting. That does properly update the register.
I tried this with https://github.com/svermeulen/vim-cutlass and did see the same behavior. Hence my asking in the StackExchange, thinking it might be some "issue" or bug with vim itself with how these remappings are done. But I was told to come here, so hopefully that's not too annoying.
Any insight would be greatly appreciated. Thank you 😄
Hey! Sorry about this issue. I'm not sure that's an issue with the plugin but I'll try to figure it out.
Can you share you're config ?
Can you also share the result of :map x and :map V
Also, fyi, if you want to quickly cut a line, you can just use xx.
Hopefully it's not too much trouble. It certainly doesn't seem like this particular plugin's issue, so please don't sink too much time into it!
For sure about xx, I was doing the simplest/dumbest thing possible for demonstrative purposes 😅
But thank you so much!
Here's the pared down config I was using for testing. It's just the lazy starter with cutlass added.
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
{
"gbprod/cutlass.nvim",
opts = {
cut_key = "x",
override_del = true,
exclude = { "ns", "nS" },
},
},
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "tokyonight" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
Also sorry, totally spaced on answering your other questions!
:map x
n xx * dd
s x * <C-O>"_cx
n x * d
x x * d
:map V
s V * <C-O>"_cV