0

Is it possible to drag and drop a selected text by pressing and holding a modifier key in Visual Studio Code? Usually, this is Ctrl+Drag. But doesn't seem to work.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Michael S.
  • 589
  • 8
  • 25
  • 1
    Ctrl + Drag works for me on Windows. What's your platform? – Álvaro González Feb 04 '22 at 12:40
  • I am on macOS currently, when using Ctrl+Click a right-click is performed. Is there another modifier? – Michael S. Feb 04 '22 at 12:56
  • 1
    Do you have `Editor: Drag and Drop` enabled? – Mark Feb 04 '22 at 14:31
  • Yes, it is enabled. I think the problem with macOS is, that system-wide Ctrl+Click means right-click. I discovered and installed [this](https://stackoverflow.com/questions/65674991/karabiner-elements-ctrl-left-click-to-left-click-doesnt-work). This seems to map correctly now after enabling my mouse in Devices - Basic configuration. Tested on desktop. No pop-up menu anymore. But in VS Code no drag & drop yet. – Michael S. Feb 07 '22 at 07:54
  • Try using the Troublershooter for keybindings. Press `F1` then type troubleshoot and select the option that says **"Toggle Keyboard shortcuts Troubleshooting"** then open the `Output Panel` (which is not the same as the terminal). Make sure you select the output named `Log (Window)`. Then see what is happening when you press CTRL. – JΛYDΞV Feb 26 '22 at 06:48
  • To give you a reference, on Linux (Typical Debian Distro) It shows `[2022-02-25 22:48:51.464] [renderer5] [info] [KeybindingService]: / Received keydown event - modifiers: [ctrl], code: ControlLeft, keyCode: 17, key: Control` -- **THEN** -- `Converted keydown event - modifiers: [ctrl], code: ControlLeft, keyCode: 5 ('Ctrl')` – JΛYDΞV Feb 26 '22 at 06:51
  • My guess is that on a mac, VSCode will register some other event that what I posted above as the output I see in my Debian OS. If this is the case, then you know its a system issue, and you have to figure out how to get the event that VSCode is looking for to register when you **A** _Either hold down the control key_, or **B** _Figure out a hack to get the same event I posted above on some other key_. – JΛYDΞV Feb 26 '22 at 06:54
  • Just to touch on a similar topic. In JetBrains IDEs (Specifically IntelliJ & CLion), You can configure keybindings for keys that are held in the lock position _(lock pos = held down)_. Hopefully VSCode will support a similar feature in the future. I know that the lock position keybindings in intelliJ is a feature that is highly praised by mac users. – JΛYDΞV Feb 26 '22 at 06:57
  • This is what I get: [2022-02-27 08:53:38.417] [renderer1] [info] [KeybindingService]: / Received keydown event - modifiers: [ctrl], code: ControlLeft, keyCode: 17, key: Control [2022-02-27 08:53:38.418] [renderer1] [info] [KeybindingService]: | Converted keydown event - modifiers: [ctrl], code: ControlLeft, keyCode: 5 ('Ctrl') [2022-02-27 08:53:38.418] [renderer1] [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase. [2022-02-27 08:53:38.561] [renderer1] [info] [KeybindingService]: + Storing single modifier for possible chord ctrl. – Michael S. Feb 27 '22 at 07:54
  • [2022-02-27 08:53:38.861] [renderer1] [info] [KeybindingService]: + Clearing single modifier due to 300ms elapsed. – Michael S. Feb 27 '22 at 07:55

2 Answers2

1

If you have the default configuration, there's no need for CTRL key. Just selecting the text and dragging it in place (using left mouse click) does the job.

Version: 1.64.2

bariscc
  • 136
  • 1
  • 7
  • 1
    Sometimes the obvious things aren't the things you try first. I've tried all modifier keys, but not without them. It works without pressing a modifier key. Perfect. – Michael S. Mar 01 '22 at 13:18
  • this doesn't copy, just moves the text. (cut & paste, not copy & paste) – motcke Oct 30 '22 at 23:28
0

Try command (⌘) + click. I believe Apple's "CTRL" key is the "⌘" key, and its "ALT" key is "CTRL" (that's why you right click was happening; ALT + click = right click).

human bean
  • 847
  • 3
  • 15