zed
zed copied to clipboard
Ability to Duplicate Line Upward
Check for existing issues
- [X] Completed
Describe the feature
In addition to the editor::DuplicateLine command, also have an editor::DuplicateLineUpward, which copies the line above the current line, and moves the cursor up to the line above. Like the default alt-shift-up behavior in VSCode.
If applicable, add mockups / screenshots to help present your vision of the feature
No response
I have some notion of how this would be done. Starting here, the function could be duplicated to create a duplicate_line_up func.
My thinking is that these lines would need to be changed somehow to copy the line to the right place:
let start = Point::new(rows.start, 0);
let end = Point::new(rows.end - 1, buffer.line_len(rows.end - 1));
let text = buffer
.text_for_range(start..end)
.chain(Some("\n"))
.collect::<String>();
edits.push((start..start, text));
I would be happy to tackle this if someone was willing to jump on and pair with me to get me started. I could take it over the finish line.
@t-eckert Any updates? This is genuinely one of the only features left (never knew I was so reliant on such an obscure thing!) that would get me to migrate to VSCode (other than Copilot Chat, but that's slightly less priority)... please let me know if you have any ideas.
You can do the following to get the desired functionality:
"bindings": {
"shift-alt-down": "editor::DuplicateLine",
"shift-alt-up": ["workspace::SendKeystrokes", "shift-alt-down up"],
}
Do these default keymaps satisfy this feature request? DuplicateLine has been extended to include the duplication direction configuration.
{
"alt-shift-up": [
"editor::DuplicateLine",
{
"move_upwards": true
}
],
"alt-shift-down": "editor::DuplicateLine"
}
@Moshyfawn this looks great! Thank you.