Option to not clear selection on copy #5461

Open
opened 2026-01-31 00:13:55 +00:00 by claunia · 6 comments
Owner

Originally created by @owenneil on GitHub (Dec 8, 2019).

Description of the new feature/enhancement

Currently when you copy text it clears your selection. While this is current behavior for some terminals, this is different than standard Windows behavior. Most Windows programs simply leave the text selected and require some other action to deselect the text. This is particularly bad if you have remapped Copy to Ctrl-C, then accidentally hitting it twice can result in killing your running process accidentally. Additionally, I frequently will copy text, then need to come back to it later to recopy, but due to this issue I have to re-select the text frequently.

I just want copy/paste to work the same here that it does in every other program.

Originally created by @owenneil on GitHub (Dec 8, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement Currently when you copy text it clears your selection. While this is current behavior for some terminals, this is different than standard Windows behavior. Most Windows programs simply leave the text selected and require some other action to deselect the text. This is particularly bad if you have remapped Copy to Ctrl-C, then accidentally hitting it twice can result in killing your running process accidentally. Additionally, I frequently will copy text, then need to come back to it later to recopy, but due to this issue I have to re-select the text frequently. I just want copy/paste to work the same here that it does in every other program. <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@DHowett-MSFT commented on GitHub (Dec 9, 2019):

This is particularly bad if you have remapped Copy to Ctrl-C,

Incidentally, the collision between copy and cancel (one of which is handled by the terminal emulator, and the other of which is handled by the remote application) is why we haven't bound Ctrl+C by default.

There's a lot of different feature requests around copying, and people have a lot of different requirements here. We should converge them, if possible.

@DHowett-MSFT commented on GitHub (Dec 9, 2019): > This is particularly bad if you have remapped Copy to Ctrl-C, Incidentally, the collision between copy and cancel (one of which is handled by the terminal emulator, and the other of which is handled by the remote application) is why we haven't bound <kbd>Ctrl+C</kbd> by default. There's a lot of different feature requests around copying, and people have a lot of different requirements here. We should converge them, if possible.
Author
Owner

@carlos-zamora commented on GitHub (Jun 5, 2020):

Just thinking out loud. Here's a few thoughts:

  • what kinds of setting should this be? Keybinding arg? Global? Profile?
    • Like copyOnSelect, I feel that this should be a global setting
  • type should definitely be bool
  • we should keep ESC as a way to clear the selection
  • passing key events to the Terminal should also clear the selection as they do now
  • what's a nice name for this?
    • persistSelectionOnCopy (default is false)

Originally thought of naming it clearSelectionOnCopy (default is true), but I've been told before that we should try and make the default false. So any thoughts as to what this setting could be called is much appreciated :) (for now I'm just going with the plan above).

EDIT: alternatively, persistentSelection or persistSelection? slightly shorter

@carlos-zamora commented on GitHub (Jun 5, 2020): Just thinking out loud. Here's a few thoughts: - what kinds of setting should this be? Keybinding arg? Global? Profile? - Like `copyOnSelect`, I feel that this should be a global setting - type should definitely be bool - we should keep <kbd>ESC</kbd> as a way to clear the selection - passing key events to the Terminal should also clear the selection as they do now - what's a nice name for this? - `persistSelectionOnCopy` (default is `false`) Originally thought of naming it `clearSelectionOnCopy` (default is `true`), but I've been told before that we should try and make the default `false`. So any thoughts as to what this setting could be called is much appreciated :) (for now I'm just going with the plan above). EDIT: alternatively, `persistentSelection` or `persistSelection`? slightly shorter
Author
Owner

@carlos-zamora commented on GitHub (Jun 5, 2020):

Here's a question:

if persistSelection is enabled, and a selection is active, what should we expect right-click to do?

  1. copy the selected text?
  2. paste what is on the clipboard?
  3. copy the selected text and paste what is on the clipboard? --> copyOnSelect

This makes me wonder if maybe a global setting isn't the right approach, and instead there should be a keybinding arg on 'copy'. Then, this could work more like a text editor, where...

  • you make a selection
  • you copy with your keybinding (selection persists)
  • you paste (selection gets cleared because text got sent to the terminal)

The only thing I dislike is that a user would have to add this keybinding arg to all of their copy keybindings. But, I think that's a small case with a minor annoyance.

@carlos-zamora commented on GitHub (Jun 5, 2020): Here's a question: if `persistSelection` is enabled, and a selection is active, what should we expect right-click to do? 1. copy the selected text? 2. paste what is on the clipboard? 3. copy the selected text and paste what is on the clipboard? --> `copyOnSelect` This makes me wonder if maybe a global setting isn't the right approach, and instead there should be a keybinding arg on `'copy'`. Then, this could work more like a text editor, where... - you make a selection - you copy with your keybinding (selection persists) - you paste (selection gets cleared because text got sent to the terminal) The only thing I dislike is that a user would have to add this keybinding arg to all of their copy keybindings. But, I think that's a small case with a minor annoyance.
Author
Owner

@YAMLcase commented on GitHub (Apr 14, 2021):

I feel like #9787 is related

@YAMLcase commented on GitHub (Apr 14, 2021): I feel like #9787 is related
Author
Owner

@zadjii-msft commented on GitHub (Jul 6, 2022):

From #13438

Should be fairly trivial to add a dismissSelection property to the copy action, defaults to true, and does what you'd expect. We should then change the enter keybinding to

        { "command": { "action": "copy", "singleLine": false, "dismissSelection": false }, "keys": "enter" },

er... maybe we don't change the defaults. Those would be the opposite of ConEmu

@zadjii-msft commented on GitHub (Jul 6, 2022): From #13438 > Should be fairly trivial to add a `dismissSelection` property to the `copy` action, defaults to true, and does what you'd expect. ~We should then change the `enter` keybinding to~ > > ```json > { "command": { "action": "copy", "singleLine": false, "dismissSelection": false }, "keys": "enter" }, > ``` > > er... maybe we don't change the defaults. Those would be the opposite of ConEmu
Author
Owner

@vladisaev12 commented on GitHub (Nov 19, 2025):

Here's a question:

if persistSelection is enabled, and a selection is active, what should we expect right-click to do?

1. copy the selected text?

2. paste what is on the clipboard?

3. copy the selected text and paste what is on the clipboard? --> `copyOnSelect`

You could take the linux approach:

(in pseudo-code)

if(currentSelection != newSelection and !newSelection.IsEmpty()) {
    PutToClipboard(newSelection);
} elif(!newSelection.IsEmpty()) {
    PasteFromClipboard(currentSelection);
}    
@vladisaev12 commented on GitHub (Nov 19, 2025): > Here's a question: > > if `persistSelection` is enabled, and a selection is active, what should we expect right-click to do? > > 1. copy the selected text? > > 2. paste what is on the clipboard? > > 3. copy the selected text and paste what is on the clipboard? --> `copyOnSelect` You could take the linux approach: (in pseudo-code) ``` if(currentSelection != newSelection and !newSelection.IsEmpty()) { PutToClipboard(newSelection); } elif(!newSelection.IsEmpty()) { PasteFromClipboard(currentSelection); } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5461