Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pressing cut key quickly after visual selection doesn't place in register #26

Open
rawhat opened this issue Jan 29, 2025 · 3 comments
Open

Comments

@rawhat
Copy link

rawhat commented Jan 29, 2025

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.

Screen.Recording.2025-01-29.at.11.32.53.AM.mov

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 😄

@gbprod
Copy link
Owner

gbprod commented Jan 30, 2025

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.

@rawhat
Copy link
Author

rawhat commented Jan 30, 2025

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 },
})

@rawhat
Copy link
Author

rawhat commented Feb 9, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants