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

Configuration: Option to use only system clipboard for all yank & paste actions #2038

Closed
thomas-profitt opened this issue Apr 8, 2022 · 8 comments
Labels
A-helix-term Area: Helix term improvements C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements

Comments

@thomas-profitt
Copy link

(Related: #1901 )

I use the following config to use the system clipboard for yank, paste, replace and delete operations:

[keys.normal]
p = ":clipboard-paste-after"
P = ":clipboard-paste-before"
y = ":clipboard-yank-join"
Y = ":clipboard-yank"
R = ":clipboard-paste-replace"
d = [":clipboard-yank-join", "delete_selection"]

[keys.select]
p = ":clipboard-paste-after"
P = ":clipboard-paste-before"
y = ":clipboard-yank-join"
Y = ":clipboard-yank"
R = ":clipboard-paste-replace"
d = [":clipboard-yank-join", "delete_selection"]

But, shouldn't using the system clipboard rather than internal registers be the default behavior?

Registers are very clean for things like when you want to do some special operation with the text in the register, but that can be implemented using the system clipboard too. It's useful to have separate registers, instead of just one, but it's much more common to want to use one register, especially when we often copy and paste text between the editor and different applications.

So, isn't it sensible for the default primary register to just be the system clipboard?

@thomas-profitt thomas-profitt added the C-enhancement Category: Improvements label Apr 8, 2022
@the-mikedavis
Copy link
Member

it's much more common to want to use one register

I disagree: I almost always use the registers instead of the system clipboard.

It probably shouldn't take so much keybinding to change the behavior if you prefer using the system clipboard all the time though. Maybe a config option that controls the default yank register would be a good middleground?

@kirawi kirawi added the C-discussion Category: Discussion or questions that doesn't represent real issues label Apr 9, 2022
@archseer
Copy link
Member

This is deliberate: I wanted to default to the system clipboard but since it's just a single clipboard it gets tricky with multiple selections: you wouldn't be able to yank all of them, just the primary one.

@thomas-profitt
Copy link
Author

In that case, this issue should be about making it possible to set the default register to the system clipboard in one's own config, without the remapping above.

It probably shouldn't take so much keybinding to change the behavior if you prefer using the system clipboard all the time though. Maybe a config option that controls the default yank register would be a good middleground?

Just like you said. There should be a "I only ever want to use one register, the system clipboard, for all yank & paste actions" option.

(I used Vim for more than a decade, probably almost every day, and I get when I might want multiple registers, like when recording and playing back macros, but I've never understood why I'd want the yank & paste actions to use anything but the system clipboard by default. I really don't get why some people prefer that UI -- why have another separate default clipboard just for your editor?)

@thomas-profitt thomas-profitt changed the title Shouldn't the system clipboard be the default clipboard for yank & paste? Configuration: Option to use only system clipboard for all yank & paste actions Apr 10, 2022
@kirawi kirawi added E-easy Call for participation: Experience needed to fix: Easy / not much A-helix-term Area: Helix term improvements E-good-first-issue Call for participation: Issues suitable for new contributors labels Nov 10, 2022
@glow12121
Copy link

glow12121 commented Feb 4, 2023

@thomas-profitt can copying, cutting and pasting be done from and to the system clipboard in insert mode, too?

@philipgiuliani
Copy link
Contributor

As far as I see, the system clipboard now works just fine with multiple selections (#6985). I personally prefer to use the system clipboard if there is a feature-parity with the registers.

@pascalkuthe pascalkuthe removed E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Jul 31, 2023
@the-mikedavis
Copy link
Member

With the yank_to_clipboard commands in #6985 this is now possible with:

# ~/.config/helix/config.toml
[keys.normal]
p = "paste_clipboard_after"
P = "paste_clipboard_before"
y = "yank_to_clipboard"
Y = "yank_joined_to_clipboard"
R = "replace_selections_with_clipboard"
d = ["yank_to_clipboard", "delete_selection_noyank"]

yank_to_clipboard has a limitation that it won't paste multiple selections if the clipboard has been modified by some other process. So if you yanked multiple selections in one terminal running Helix, you couldn't paste those multiple selections into another pane running a separate Helix instance. It might be possible to resolve that rough edge through #312 specifically for yanking and pasting from Helix instances, but we can't really use the clipboard the exact same way as a register and also have the clipboard usable from other processes.

We don't want to make this behavior the default: using the clipboard for each yank can unexpectedly clobber the clipboard if you don't know you're yanking to the clipboard and it can add a lot of junk to clipboard history if you're using a tool like clipman. This being configurable is the goal for those who like using the clipboard by default. We've discussed this internally and don't want to add configuration options for things that can be accomplished through keybinding though, so I'm closing this out as not-planned. Those looking for this behavior should use the above config snippet.

@jyn514
Copy link
Contributor

jyn514 commented Aug 11, 2024

With the yank_to_clipboard commands in #6985 this is now possible with:

this is not quite the same, because it does not allow overriding the clipboard with "% (for example). would it be possible to add a new command that takes the selected clipboard into account? or alternatively, go with the original solution and allow configuring the default clipboard for the default paste action?

@the-mikedavis
Copy link
Member

Hmm yeah that's a good point. I was originally hesitant of #11430 but it might be the better solution here than remapping since I don't think it makes sense for these clipboard commands to accept a different register to yank into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

8 participants