microsoft/vscode

Support to drag and drop selected text

curtw opened this issue Β· 88 comments

curtw commented

In Microsoft Visual Studio Professional you can click+hold on selected text and then drag that text to a new location. Like a cut/paste operation by dragging/dropping. Requesting that VS Code support this feature. Thanks!

πŸ‘ Except I think you don't have to hold ctrl just to cut/paste - ctrl once dragging makes it copy instead of cut, right? But regular drag gets rid of the original, moves it to the new location.

πŸ‘ +1
Agree with @MrAndMrsK .

+1, commenting to get notification. Really miss that.

Agreed.

NEEEEED! I use this constantly! feels alien without it and so long winded..

+1 this is a must have

It took more than one year for them to implement this feature.......

Spown commented

@wmjordan how much did you pay for VSCode?

@Spown sorry for duplicate. Deleted.

no comments re: being able to drop a library item from the directory tree into a view to set the path for css / js etc libraries --- a la Visual Studio

What's the technical holdback on drag and drop of selected text?

Spown commented

@reactivize I don't think its technical. I think nobody on the dev team thinks its worth spending time onto because nobody of them uses this coding style. VSCode was meant to be used without taking your hands away from the keyboard, hence no button palettes, a textual command palette, no miniwindows, etc.

They already kinda separated Monaco editor from the core so maybe it would be possible in the future to plug in a different editor, like Ace (however I don't think so, since hardly any of the available editors offer debugger support, ie breakpoints) that already supports D&D. But a standardized interface between core and wrapped editor is needed for that and this can be even more difficult to implement.

@reactivize There is no technical holdback, each milestone we pick features from the backlog to implement. We use thumbs up counts and comment counts as metrics to determine the community desire for a certain feature and then we use our best judgement (effort vs rewards, short-term vs long-term benefits) to pick what to work on.

Starting up some development, decided to use this tool because of the debugger, and this was really annoying to find missing.

Adding both my thumbs up to the request for this feature. Its driving me crazy that its not there.

Must have!!!
Especially dragging text between docs, editors, drag text to another apps, such as browser, and vice versa.

A feature that is in visual studio obviously should be in visual studio code as well.

zaus commented

It's just weird that this is the only app I've ever seen that lets you type that doesn't let you drag text as well. Even web browsers let you drag text.

This is basic text editor feature, really need this! I keep trying to do it then it just reselects :(

I really love the drag and drop feature and ctrl+ drag and drop feature for duplicating text selection, this way you don't need to overwrite your clipboard.

This would be a really nice little addition, I use this feature all the time in other editors. Hope I can help bump this up the priority list a bit.

I won't use VS Code unless this issue is solved.

Agreed-- the current VSCode editor needs these basic features (e.g. drang-n-drop text, column select text, multi-line edit), it feels crude/unfinished otherwise.

You can already column select text shift+ alt+click, and you do have multi cursor ctrl+alt+arrows(although that will rotate ur display unless u change the shortcut :p). Drag to move text would be nice though, but with those two I find that I want to use drag and drop less. Vscode was designed to be ran from a keyboard.

@Devcon4

Vscode was designed to be ran from a keyboard.

vscode should be designed to work efficiently with both keyboard & mouse :)

thnx for the key combos!

Seriously, how long would it take to code this feature? And people wonder why MS keeps losing.

I see this issue/request has been raised since 11 months now... and still not fixed in Visual Studio Code 1.6.1. This is a basic editor functionality that every coder uses... I don't understand why it has not been implemented since the beginning (we see that a lot of more complex useful functionalities have been implemented).
I'm waiting desperately since months, testing this at each new release... Could we just have a status from Microsoft dev team? Have they taken this request into account? Do they have a technical difficulty to implement this?

In defense of Open Source Software and Microsoft, I write this. The code is open; if you have a particular need and the developer/maintainer doesn't fix it, you certainly can. There is no reason to be so demanding and rude about it. This software is free, both in money you have to pay to use it/get it, and in that it's available for you to review, update, and change. If it's good, they'll take your changes. The number of requests for features, updates, etc for this awesome piece of software is overwhelming, and they can't get to everything right away. Part of the philosophy of Open Source is 'scratch your own itch'. There is nothing that prevents you from getting together with other developers to create changes that you want/need and submit them back to the developer. We are a community. Demanding someone else do something for you is not the way to go. Offering help and solutions for troubles you are having (even just really good bug reports) is how to move the software forward.

This is a basic feature of every GUI based source code text editor. Sublime, Notepad++, Visual Studio Pro, etc support that feature. I understand the desire to prioritize keyboard input but I assume a lot of people are like me and do a mix of keyboard and mouse input when editing files.
Somebody also mentioned that this method prevents overwriting the clipboard which is a good point.

@rhires well in that case why have this open bug tracker at all. Why not let everyone and their grandma make a pull request to fix every little thing they come across. No one here is "demanding" anything because putting up a demand requires authority for it to have any success.

Also your argument can be applied to literally every feature request of any open source project ever. Devs take this kind of feedback to assess user trends and focus their effort appropriately. Every "demand" is just another data point that will help them make better decisions.

OMG, it is terrible that @alexandrudima removed the assignment to this issue.

Don't take the Assignee as a measure for when a feature will be done. The field to look at is the Milestone. You can bring feature requests higher on our list of To-Dos by upvoting them. We pick issues with many upvotes to work on each month.

I've unassigned myself to be able to manage my issues better. I am slowly going though issues assigned to me and removing my assignment until the feature request gets put on the plan.

I now believe that there is no insurmountable technical barrier to solve this issue.
Atom, another editor sharing the same component as VS Code, has the same issue and this package has solved it:
https://atom.io/packages/simple-drag-drop-text

Oh, it's been more than a year, but I'm still waiting...

I now believe that there is no insurmountable technical barrier preventing the implementation to solve this issue.
Atom, another editor sharing the same component as VS Code, has the same issue and this package has solved it:
https://atom.io/packages/simple-drag-drop-text

Or is there anyone who can make an extension like that?

Sublime suffers from this on Linux even though it works fine on Windows version; yet applications such as VS Code can't even do this on Windows.

Drag'n'drop and printers; the banes of my computing life.

@rhires I agree with you, and sometime I said that too (in other contexts / projects), but don't forget that users of VSCode have various backgrounds, from HTML coders to Python programmers, etc. so might just lack the competence to do such changes. That's not, eg. just a JS library used by JS devs complaining about some lack of feature...
That said, indeed, the tone used by some people is a bit rude...

@dvader I agree, I guess I used D'n'D primarily to avoid clobbering the clipboard, and I am too used to it to code without it, that's why I test VSCode from time to time, then uninstall it... πŸ˜„
Today I have a clipboard manager, but well, I don't want it cluttered with snippets too...
Admittedly, often D'n'D might be slower than doing the manip with keyboard (aiming at target can be delicate...) but I am a visual guy: I use the keyboard a lot, of course, but the mouse too. Taking a few lines and dragging them at their new place, for example, is visually more satisfying... πŸ˜‰

@wmjordan Atom is based on another editor component, which had D'n'D support from the start, I guess the package just exposed it. It would be harder with this one, I guess. Not impossible, I hope.

I'm definitely πŸ‘ for this feature, but wanted to offer some comfort to those waiting.

There was a time when Sublime Text didn't have this feature either. It seems "small" features like this are the growing pains of young editors gaining popularity. (It's also amusing how similar the conversations are.) It's likely this will get resolved.

In the meantime, keep on +1'ing this issue to show a signal of interest and try to appreciate the good (there's already a lot!) while VS Code matures.

The feature is a must!!
+1

Inside a file you can move code-snippets using alt+arrow keys

@sir-marc Thanks for the input but that is not at all what people here are looking for.

@sir-marc
Moving the code Up/Down is not the same as dragging & dropping a selection; it's much slower!!!

@erocheleau +1

@klaygor +1
I just realised there is no printer either!! Come on guys! please! It cannot be more basic than that?
I just hope we won't be told to copy and paste it somewhere else to print it out...

+1 for drag & drop / ctrl + drag & drop

ε€ͺιœ€θ¦θΏ™δΈͺεŠŸθƒ½ε•¦οΌŒεŠ ζ²ΉεŠ ζ²ΉοΌŒζœŸεΎ…γ€‚γ€‚γ€‚
thanks for vs code's help

Cannot believe it ... this is the most basic editing feature but missing from VS Code.

Please people. Refrain from commenting here if you don't bring useful information. Now GitHub allows you to "vote" on an issue by adding a πŸ‘ on the original report. This avoids to send notifications of no real value to everybody.

Drag and drop is desperately needed. There are a whole lot of reasons to use VSCode even if you are not a keyboard-only guy. Please add this feature! Please!

Pleas Add this feature this is an essential feature for any code editor!

I would love to have this feature + D&D from files tree to insert file path to the editor (maybe with ctrl).
thank you.

This feature is must needed absolutely, please add this feature for vscode. Thanks!

Yep, we need the feature indeed.

+1
No one knows an extension?

Because usually the text is close to the target position, you can use "move line" meanwhile:
Cursor on line -> Alt+Up or Alt+Down (and alt+shift for copy)

Grix commented

Another +1

As a user who sometimes has difficulty using the keyboard with one hand, drag-n-drop is a boon at times. Strange but true, this is the biggest gripe I have with Code. Keyboard-centric UI is fail for some people. The challenge isn't learning key bindings... it's pressing the cursor keys that is hard.

I don't know how but I heard your voice on Sunday and I'm working on it now. Let's see if we can make it by the end of Feb release. Drag and drop breaks part of our existing experience so I'd like to do careful testing against it but there is no blocker. Cheers ❀️

Is it also able to add drag and drop API into the vscode? This could be useful for some usages, for example, I can create an extension help to edit the markdown, when I want to insert a image, i can simply drag the image from the folder into the editor.

Spown commented

@Jasonlhy lets not overextend. first things first. this issue is called "...drag and drop selected text"

Just drag-n-drop of selected text alone would solve the vast majority of my editing problems, because it fills so much of my every day. Thanks @rebornix, life is about to get sweeter :-)

I can't believe this is even a request. It's a normal feature in all but the most arcane of text editors. Trying to move from Visual Studio to Visual Studio Code shouldn't be this difficult. :(

That said, great job on include Alt+Up/Down to move lines πŸ‘ - I loved it when you introduced this to VS2013 (?) and I'm really happy it's in VSCode :)

+1 for this as well. I find myself dragging code and nothing happens....

+1 and kudos to @rebornix for even considering taking this on. D&D is not trivial. The edge cases alone are a headache: drag to beginning/end of file, drop into the selected text, drop at start/end of selected text, drop into another instance of the same file, drag off the editor window, escaping the D&D mid-drag, drag to top/bottom of editor window to cause scrolling, drag to edge of window on long line to drop at the end of line, copy instead of move if Ctrl is held, (or other key bindings, of course), "undo D&D" for all cases etc. It's no wonder that this feature is missing from new editors.

@rotan-hanrahan thank you very much, you helped me create a thorough test plan for this feature :)

Would it be a problem to have a drop-handler in the extension api?

I am thinking of a feature of dropping images on markdown code and - like here on github - getting the image uploaded (in this case added to a project).

I second that ^. Would be great to see API hooks for workspace drop events.

Usage example: If you render a list of components / plugins / whatever in the second tab (as a read-only HTML), you can drag and drop them to the workspace then. I'll be happy to collaborate on this feature if needed.

Thank you x 10,000 to @rebornix and everyone who contributed to this. I'm enjoying this now in 1.10.0, and life is more pleasant now! This feature makes a big difference for me and I'm truly delighted. I worked for 12 years at MS long ago, including several in the Visual Studio and other Dev Div product groups. I've never been so happy to see a few feature ship, seriously. Thanks again!

Thank you @rebornix very much.
I am using VS Code now.

Great start, thanks for adding this! Some notes for polish on the final product (not sure if there's a better place to put these):

  • The mouse cursor should change to the default arrow when you hover over a selection that can be dragged and while dragging it.
  • A user should not be able to drag a selection into itself (technically you can't, but the mouse cursor and target cursor both lead you to believe you can).
  • A user should be able to hold CTRL (or whatever in other operating systems) to copy the selection instead of move it.

Visual Studio and most editors with drag/drop support do these things if you need an example.

Thanks again!!

I second @langdonx suggestions, particularly the one about using CTRL+drag to copy.

@langdonx @rebornix For MVP it's a great start, but it needs some finer tuning, for instance

  • dragging selected text between left and right tab
  • dragging selected text between VS Code and other app, in both ways, just like it works in a browser.
  • dragging in column selection mode
  • pressing Esc when dragging should cancel the event altogether. Now after pressing Esc you can start typing, but the text is dropped once you release the mouse anyway.

I mentioned previously some of the failing test cases that have been raised since the preview of the @rebornix D&D support was released. This D&D feature enhancement, limited as it is, is still a massive improvement over having no D&D support at all. I would like to point out that the "drag to top/bottom of window to cause scrolling" appears to work despite the (closed) test cases documentation #21012 stating that this functionality is not supported. Seems we got lucky with this one.

As people seem to be contributing to the shopping list of must-haves, let me add this proposal: drag selected text over the title tab of an open file in VSC (other than the current file in which the text is selected) so that the hovered-over tab becomes the active document, allowing the user to drag text between files. This would be a bit like the way that tabs in the Windows task bar can activate the corresponding window/application as a drop target when you hover over the tab while dragging. (And please note that this isn't a must-have, but it will be pleasant to see working some day.)

Not knowing where to comment on the feature, I am adding it here.
Regarding the comment from @langdonx:

  • The mouse cursor should change to the default arrow when you hover over a selection that can be dragged and while dragging it.

Looking at other programs, the cursors actually look like so:

  1. Hover (as in the comment): arrow over
  2. Move: move arrow
  3. Copy (holding the Ctrl key): copy arrow

@dvader the mouse pointer style update is coming in tomorrow's Insider

DND

default

DND with Alt/Ctrl Key pressed

copy

@Daivuk you should be able to copy instead of just cutting.

When is this coming to OSX?

@rebornix is there a plan to use the standard Windows drag cursors that @dvader shown above? The green Copy cursor looks a bit strange.

This is now supported as of Feb 2017 release (1.10.1) but it is disabled by default.

To enable it: Go to File > Preferences > Settings and add this line "editor.dragAndDrop": true

Source: https://code.visualstudio.com/updates/v1_10#_preview-drag-and-drop-selected-text

Happy to see the continual progress on this. Just got the March release and noticed one minor (but annoying) issue:

  • In VS Code, the cursor (with copy indication) only changes on mouse move.
  • In VS 20xx, while dragging text you can press and release CTRL to affect the mouse cursor.

My typical workflow is, 1) select text, 2) drag text, 3) hold control, 4) drop text. With this workflow, since my mouse is still, it's not clear that the text will be copied when I release the mouse.

Thanks for all the hard work!

CC: @rebornix (not sure who else to CC) =[

@langdonx it's a valid feature request, do you want to create an issue for me?

Cross reference #24547

Drag and drop is working fine in visual code but the same code is not updated in Monaco editor ?
Monaco Editor
When it will be avialable ?

Wow, It's amazing that this feature has been already implemented into VS Code!
Question: Could you feature the comment as a solution for future visitors?

#1046 (comment)

@DRSDavidSoft do you mind tell me how to feature a comment as a solution?

@wewake4 we updated Monaco on Mar 3rd, you should be able to have this feature.