VSCode Keyboard Shortcuts

Scott accidentally hit the wrong key combination when attempting to comment out a block of code and brought up some clipboard viewer; and, in attempting to identify what he hit, I came across published keyboard shortcuts for Windows and Linux (I still haven’t found the key combo he hit, so I suspect he hit a desktop manager shortcut). There are a few time savers in the list:

  • Alt in combination with the up/down arrow keys moves the current line up or down
  • Shift+alt in combination with the up/down arrow keys will create a copy of the current line up or down
  • You do not need to select a line to copy/cut — using Ctrl+c or Ctrl+x with no selection will copy/cut the entire current line
  • Ctrl+K followed by the letter P copies the path to the active file
  • Ctrl+K followed by the letter R opens a new file explorer window to the location of the active file
  • Shift+Alt in combination with the letter i activates a ‘multiple cursor’ mode. Each line selected when you use the shortcut will get a cursor at the end of it

And whatever you type will be duplicated at each cursor. To leave multi-cursor mode, simply click elsewhere within the document — you’ll have one cursor where you clicked.

If you want multiple cursors on discontiguous lines, hold the Alt key as you click — a cursor will appear each location you click (not at the end of the line where you have clicked, literally the location at which you clicked — including multiple cursors per line.) If you add a cursor in the wrong location, click it again to clear that cursor.

Leave a Reply

Your email address will not be published. Required fields are marked *