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

Mulitline copy/pasting #11007

Closed
vsamy opened this issue Aug 26, 2016 · 19 comments
Closed

Mulitline copy/pasting #11007

vsamy opened this issue Aug 26, 2016 · 19 comments
Assignees
Labels
editor-multicursor Editor multiple cursor issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded

Comments

@vsamy
Copy link

vsamy commented Aug 26, 2016

  • VSCode Version: 1.4.0
  • OS Version: ubuntu 14.04

Steps to Reproduce:

  1. shift+alt to get multicursors on several lines
  2. ctrl+x to cut
  3. ctrl+c to paste

out

@sandy081
Copy link
Member

@vsamy I am not sure if I understand what is your requirement / issue here. Can you please elaborate more?

@sandy081 sandy081 added the info-needed Issue requires more information from poster label Aug 26, 2016
@vsamy
Copy link
Author

vsamy commented Aug 29, 2016

Sure.

In vscode to copy/cut paste a line you usually do a ctrl+x/ctrl+c then a ctrl+v. This is very convenient but it only can be done one line at a time. If i have multicursor and try to cut/copy paste all the line at the same time it does not work and leave blank lines. Maybe i missed a shorcut on multiline copy pasting.

It is like a '4dd' 'p' in vim for example.

I hope it is more clear to you now.

@sandy081 sandy081 removed the info-needed Issue requires more information from poster label Aug 29, 2016
@Bill-Stewart
Copy link

You can do this by selecting all or part of the lines, press command for expandLineSelection (default ctrl+i), then cut/copy/paste or reposition lines using moveLinesUp (default alt+up) and/or moveLinesDown (default alt+down).

@vsamy
Copy link
Author

vsamy commented Sep 15, 2016

Ok, thank you for the tips.

@Bill-Stewart
Copy link

@vsamy - does this answer it - can this issue be closed?

@vsamy
Copy link
Author

vsamy commented Sep 26, 2016

Sorry for the late answer.

It does give me a way to bypass my problem and it works properly. It depends on whether or not you do want to correct this copy/paste problem or not.

@Bill-Stewart
Copy link

@vsamy - what copy/paste problem are you referring to?

@vsamy
Copy link
Author

vsamy commented Sep 27, 2016

The copy/paste when having multicursors.

@Bill-Stewart
Copy link

What behavior were you expecting?

@vsamy
Copy link
Author

vsamy commented Sep 27, 2016

Ok let's get back from zero.

The aim is to copy/paste multiple lines at the same time.
For example if i want to cut line 10 to 14 and paste it in another file.
You suggested to use ctrl+i to get the 5 lines and paste it. It works but when pasting it it does not behaves like a ctrl+x/ctrl+v on one line. Typically when doing it on one line, it pastes over the current cursor line not at the cursor position.
When getting multiline cursors (shift+alt+(down/up/clic)) and copying it (ctrl+c). It does paste (ctrl+v) over the current cursor but the lines are blank lines (as my first comment's gif shows).

Note for me, shift+alt+down does not behaves the same on windows and ubuntu (is it just me ?).

@Bill-Stewart
Copy link

I am not sure I understand. The expandLineSelection (default ctrl+i) command selects all entire lines where there are cursors or where there is a current selection. If you want paste to replace lines, then select the lines you want to replace, then paste. (That is, paste will replace any selected text.)

@vsamy
Copy link
Author

vsamy commented Sep 27, 2016

The aim is not to replace lines but rather add the copied lines to another location.
Also when having multicursors and doing a ctrl+i then a ctrl+x leaves blank lines which needs to be deleted.

Im just saying that having multicursors and doing a ctrl+x/ctrl+v should work the same (but for several lines) as doing it with one cursor.

@Bill-Stewart
Copy link

OK, I think I understand. If you use multiple cursors and use expandLineSelection and then cut or delete, then yes it leaves blank lines. What you are saying: If there are multiple cursors and entire lines are selected using expandLineSelection, then cut or delete should delete the lines rather than leaving them empty. Is this correct?

@vsamy
Copy link
Author

vsamy commented Oct 5, 2016

From what i understood there are two problems:

When using expandLineSelection:

  • ctrl+x: leaves blank lines which needs to be deleted afterwards
  • ctrl+v: Paste works fine

When not using expandLineSelection (only get multiple cursors by doing shift+alt+down/up):

  • ctrl+x: Works fine. Does not leave blank lines.
  • ctrl+v: Paste is bad. Paste blank lines instead of the text cut before.

@Bill-Stewart
Copy link

Bill-Stewart commented Oct 7, 2016

For first use case with expandLineSelection: Yes, the cut leaves a blank line because the final newline is not selected when you use expandLineSelection (you can observe this by looking carefully at the selection). You can work around it by pressing shift+right after the expandLineSelection command. It is a good feature request to say "we would like expandLineSelection to include the final newline".

I think the answer in your second use case is not to expect that selecting only ends of lines will work for copy/cut entire lines. The editor's behavior in this case is possibly a bug, but you don't need multiple cursors to select/copy/cut entire lines.

@vsamy
Copy link
Author

vsamy commented Oct 10, 2016

"you don't need multiple cursors to select/copy/cut entire lines". True enough.
It is just it would much faster to copy/cut/paste this way (only one command to get all the lines). The first option demands more to do :)

@Bill-Stewart
Copy link

There are a couple of extensions that may provide the "select entire lines" feature you are looking for?

https://marketplace.visualstudio.com/items?itemName=bigous.vscode-multi-line-tricks

https://marketplace.visualstudio.com/items?itemName=andreaskian.vscode-select-line

@alexdima alexdima added feature-request Request for new features or functionality editor-multicursor Editor multiple cursor issues editor labels Oct 27, 2016
@alexdima alexdima removed their assignment Oct 27, 2016
@alexdima alexdima added this to the Backlog milestone Oct 27, 2016
@usernamehw
Copy link
Contributor

But ... but ... this is unexpected. Look how it is done in Sublime Text or Atom:

sublime atom

And vscode just swallows your multi-line targets:
vscode

As I see it can be done by expandLineSelection and then cut/copy.
newvidvscode

So why it isn't the default behavior?

@Bill-Stewart
Copy link

I have disabled editor.emptySelectionClipboard, so when I select only end-of-lines the "cut" action does nothing. This seems a bit odd, because if I press the delete key, vscode joins the lines (this is expected). When editor.emptySelectionClipboard is enabled, the behavior is different. Interesting.

@alexdima alexdima modified the milestones: Backlog, September 2017 Sep 21, 2017
@alexdima alexdima self-assigned this Sep 21, 2017
@jrieken jrieken added the verification-needed Verification of issue is requested label Sep 26, 2017
@roblourens roblourens added the verified Verification succeeded label Sep 27, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-multicursor Editor multiple cursor issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants