helix
helix copied to clipboard
feat: New command `:paste-join`
Sometimes I have like 10 selections, yank them with y only to realize i want them all in a single place. So what I do is usually select everything again and use :yank-join, which joins all of my selections so I can paste it with just 1 cursor
The above experience would be more pleasant if I could take all of my 10 yanked selections and paste them into 1 place. The :paste-join command does exactly that.
In this file
[one]
[two
[three]
four
five
If you have the first 3 words selected, as outlined by [...] and you press y to yank it then place your cursor at [ ]:
one
two
three
[ ]
four
five
using :paste-join will join whatever you copied with a newline
one
two
three
[one
two
three]
four
five
Without having to create multiple cursors, or use yank-join!
New typed command
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ Join selections with a separator and paste │
│ Aliases: pj │
│ Flags: │
│ --separator/-s <arg> Separator between joined selections (Default: newline) │
│ --count/-c <arg> How many times to paste │
│ --position/-p <arg> Location of where to paste │
│ --register/-r <arg> Paste from this register │
└────────────────────────────────────────────────────────────────────────────────────────┘
:paste-join
New static commands
| Name | Description | Default keybinds |
|---|---|---|
paste_before_joined_with_newline |
Join all selections with a newline and paste before cursor | |
paste_after_joined_with_newline |
Join all selections with a newline and paste after cursor | |
replace_joined_with_newline |
Replace selection with all selections joined with a newline |
Supercedes https://github.com/helix-editor/helix/pull/4694
Looks great, something from kakoune I have missed often.
Could you also make a normal command version of this? Whrn mapping these commands a normal command where you can set the register with " would ve more useful.
I would like to replicate the kaklune bindings:
- a-p paste-all after cursor
- a-P paster-all before cursor
- a-R replace-all
(Potentially these three variants can also be flags for the typable command)
Looks great, something from kakoune I have missed often.
Could you also make a normal command version of this? Whrn mapping these commands a normal command where you can set the register with " would ve more useful.
I would like to replicate the kaklune bindings:
* a-p paste-all after cursor * a-P paster-all before cursor * a-R replace-all(Potentially these three variants can also be flags for the typable command)
I made normal versions of the 3 commands you mentioned
paste_after_joined_with_newlinebounded toC-ppaste_before_joined_with_newlinebounded toC-Preplace_joined_with_newlinebounded toC-R
The typed command now accepts "replace" which means the above commands can also be imitated by using the typed commands
I deviated from Kakoune's A-p and A-P because currently select_prev_sibling is bound to A-p which would create a conflict.
And both C-p and C-P were available.
Deviated from A-R for replace, to be consistent with the above C-p and C-P
I also added default mapping C-y for yank_joined for consistency
Running into a bug where it broke the existing commands : [replace_with_yanked, replace_selections_with_keyboard]
I am yanking this #[word]
when i replace #[this] using `R`
I should get
I am yanking this #[word]
when i replace #[word] using `R`
But I'm getting
I am yanking this #[word]
when i replace #[wordwordwordwordword] using `R`
same behaviour with space-R that is word is copied 5 times over.running into a bug where the commands : [replace_with_yanked, replace_selections_with_keyboard] are misbehaving.
Running into a bug where it broke the existing commands : [replace_with_yanked, replace_selections_with_keyboard]
I am yanking this #[word]when i replace #[this] using `R`I should get
I am yanking this #[word]when i replace #[word] using `R`But I'm getting
I am yanking this #[word]when i replace #[wordwordwordwordword] using `R`same behaviour with space-R that is word is copied 5 times over.running into a bug where the commands : [replace_with_yanked, replace_selections_with_keyboard] are misbehaving.
Thanks for noticing it. The issue was passing 2 usize parameters in an incorrect order
Since there is a typable command I don't think we need to add default keybindings for these. Or at least I'd prefer to discuss that in a separate PR. The keymap space is limited and this would occupy four spots for commands you can execute in command mode
Ok, I've removed the default mappings
This is a popular feature :)
Imo https://github.com/helix-editor/helix/pull/4694 would be greatly preferable to this PR because:
- it preserves separate selections
- it is a more atomic operation, not mixing in logically separate behavior (inserting newlines)
With https://github.com/helix-editor/helix/pull/4694 I can produce this separate lines outcome by doing the paste join, and then leveraging the selections to insert the newlines. With this PR we don't have away of reconstructing the functionality of having multiple selections.
I have updated (and added to) https://github.com/helix-editor/helix/pull/4694 at: https://github.com/helix-editor/helix/pull/13698
This is a popular feature :)
Imo #4694 would be greatly preferable to this PR because:
* it preserves separate selections * it is a more atomic operation, not mixing in logically separate behavior (inserting newlines)With #4694 I can produce this separate lines outcome by doing the paste join, and then leveraging the selections to insert the newlines. With this PR we don't have away of reconstructing the functionality of having multiple selections.
I have updated (and added to) #4694 at: #13698
This is a popular feature :)
Imo #4694 would be greatly preferable to this PR because:
* it preserves separate selections * it is a more atomic operation, not mixing in logically separate behavior (inserting newlines)With #4694 I can produce this separate lines outcome by doing the paste join, and then leveraging the selections to insert the newlines. With this PR we don't have away of reconstructing the functionality of having multiple selections.
I have updated (and added to) #4694 at: #13698
The benefit of this PR is that it adds typed commands for more granular control
The static commands are simply shorthands for the typed commands with newline as the separator
I'm not sure what is the benefit of the PR you sent, when the changes you mentioned can be implemented here quite easily (paste_joined_before and paste_joined_after) without a newline?
I'm not sure what is the benefit of the PR you sent, when the changes you mentioned can be implemented here quite easily (
paste_joined_beforeandpaste_joined_after) without a newline?
The key feature that is missing here is not static commands to paste without a newline, it is pasting without joining the selections.
See how many selections result: https://github.com/helix-editor/helix/pull/13698/files#diff-de6d53c9114aa1dd8644d67767043ed85f30780e0a0197e49501fc9967443da1
This state preserving the selections enables you to do many more things. You can compose other arbitrary edit actions, instead of only being able to do what the typed command flags support.