Skip to content

Fill buffer with selected text#12

Open
twiclo wants to merge 1 commit intohrantzsch:masterfrom
twiclo:master
Open

Fill buffer with selected text#12
twiclo wants to merge 1 commit intohrantzsch:masterfrom
twiclo:master

Conversation

@twiclo
Copy link
Copy Markdown

@twiclo twiclo commented May 31, 2023

Populate vim buffer with contents of clipboard. Make sure to press Ctrl+A before running your vimclip keybinding

Populate vim buffer with contents of clipboard. Make sure to press Ctrl+A before running your vimclip keybinding
@hrantzsch
Copy link
Copy Markdown
Owner

This is a very nice idea, thanks for that.

I'm a bit worried that it might be surprising to find whatever text you last selected prefilled in the buffer. Maybe we can make it more explicit by providing an additional parameter to enter this "mode"? This way we could bind it to a different key. What do you think?

Side note: I wonder if it wouldn't be better to use the clipboard section (-b) for populating the temp file as well. IMO this would be more consistent.

@twiclo
Copy link
Copy Markdown
Author

twiclo commented Jun 1, 2023

Sure, I can add arguments to vimclip. Might as well do -p for "Insert from primary" and -b for "Fill from clipboard"

I like -p because then all you have to do is hit Ctrl+A then your keybinding. I'm wrestling with xmonad to run that Ctrl+A for me before launching vimclip and then pasting automatically once I close the vim instance.

I've got a busy weekend ahead of me so give me about a week to make these changes

@hrantzsch
Copy link
Copy Markdown
Owner

hrantzsch commented Jun 1, 2023

I thought of something else and took the occasion to restructure the script a bit. The command to fill the clipboard can now be set via an environment variable VIMCLIP_CLIPBOARD_COMMAND (this will also help out wayland users). I haven't merged it yet, if you have the time, please give it a look: https://github.com/hrantzsch/vimclip/blob/v2/vimclip

I imagine we could use a similar approach to pre-fill the temp file. For example check if VIMCLIP_PREFILL_COMMAND (or whatever) is set and if it is, do it. This also gives maximum flexibility regarding where to fill the buffer from.

Let me know if you think this is a good idea, then I'll merge so you can adapt your PR.

@twiclo
Copy link
Copy Markdown
Author

twiclo commented Jun 2, 2023

Looks good to me

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

Successfully merging this pull request may close these issues.

2 participants