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

[Feature Request]: setting the clipboard as the default register #1214

Open
angelacastaneda opened this issue Oct 29, 2024 · 4 comments
Open

Comments

@angelacastaneda
Copy link

What feature would you like to see?

what's the best way of making the clipboard the default register in vis? where copying, pasting, and all the rest is no different than clipboard = "unnamedplus" in neovim?

this patch everyone got working for them is very outdated: #1003 (comment)

there was this lua code I found for setting it defacto (I couldn't get it working in my visrc):

vis:map(vis.modes.VISUAL, ' y', '"+y')
vis:map(vis.modes.VISUAL, ' p', '"+p')

but it seems less complete than manually patching in the default register.

someone made a quick patch for me:

diff --git a/vis-registers.c b/vis-registers.c
index 6e21a58..490ee77 100644
--- a/vis-registers.c
+++ b/vis-registers.c
@@ -152,7 +152,9 @@ bool register_slot_put_range(Vis *vis, Register *reg, size_t slot, Text *txt, Fi
 		if (len == SIZE_MAX || !buffer_reserve(buf, len+1))
 			return false;
 		buf->len = text_bytes_get(txt, range->start, len, buf->data);
-		return buffer_append(buf, "\0", 1);
+		if (!buffer_append(buf, "\0", 1))
+			return false;
+		/* fallthrough */
 	}
 	case REGISTER_CLIPBOARD:
 	{

it gets yank working but not paste, and I'm not confident enough in my C to know how sturdy this will actually hold up.

Please share lua and/or C patches below. I am grateful to all that help me detach myself from neovim.

@urosmikanovic
Copy link

urosmikanovic commented Oct 29, 2024

This works ok for me.

		vis:map(m.NORMAL,      'y', '<vis-register>+<vis-operator-yank>')
		vis:map(m.VISUAL,      'y', '<vis-register>+<vis-operator-yank>')
		vis:map(m.VISUAL_LINE, 'y', '<vis-register>+<vis-operator-yank>')
		vis:map(m.NORMAL,      'd', '<vis-register>+<vis-operator-delete>')
		vis:map(m.VISUAL,      'd', '<vis-register>+<vis-operator-delete>')
		vis:map(m.VISUAL_LINE, 'd', '<vis-register>+<vis-operator-delete>')
		vis:map(m.NORMAL,      'p', '<vis-register>+<vis-put-after>')
		vis:map(m.VISUAL,      'p', '<vis-register>+<vis-put-after>')
		vis:map(m.VISUAL_LINE, 'p', '<vis-register>+<vis-put-after>')
		vis:map(m.NORMAL,      'P', '<vis-register>+<vis-put-before>')
		vis:map(m.VISUAL,      'P', '<vis-register>+<vis-put-before>')
		vis:map(m.VISUAL_LINE, 'P', '<vis-register>+<vis-put-before>')

@angelacastaneda
Copy link
Author

angelacastaneda commented Oct 29, 2024

@urosmikanovic thanks. seems pretty thorough, but you've got duplicates with VISUAL_LINE delete and NORMAL yank.

@mcepl
Copy link
Contributor

mcepl commented Nov 1, 2024

Many times duplicate bug, see e.g. #1003

@angelacastaneda
Copy link
Author

I mentioned a patch from that issue above. it is outdated however, so I wanted to open a new issue.

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

No branches or pull requests

3 participants