Top 12 keyboard shortcuts on VScode

Top 12 keyboard shortcuts on VScode

We all want be productive on VScode, that's why i'm writing this article, to share with you my top 12 tips and tricks that can help you during your coding sessions.

First of all, the shortcuts that i'm going to show can be modified with custom keys using Settings >> Keyboard Shortcuts, to reset default's values its possible type User in the search bar and see under source the tag User to identify the shorcuts modified, with a right click its possible reset the keybindings. In the case a shortcut has been deleted and we dont rember the default values we can use the top right icon "Open Keyboard shortcuts (JSON)" to view all the changes that we made (We can delete the code to restore the default values ).

vscodeeditedshorts.png

  1. Toggle line comment (ctrl + /) its possible comment and uncomment a line or a block of code.
  2. Change all occurences (ctrl + f2 or ctrl + shift +l) after you have selected a word or with the line cursor inside the word will be selected all the occurence of that word and typing something all the occurrence will be changed.
  3. Copy Line (shift + alt + up/down) will be duplicated the current line up or down.
  4. Add cursor abow/below (ctrl + alt + up/down) will be added a new cursor at the same position abow/below or at the end if the length of the new line is less than the current one.
  5. Go to bracket (ctrl + shift + ) to move directly to the respective bracket
  6. Go to file (ctrl + p) to move quickly to a file knowing its name. To use effectively this shortcut it's necessary to have a good knowledge of the structure of the project to know the existing files.
  7. Mouve line (alt + up/down) switches the current line with the above one or the bottom one.
  8. Select line (ctrl + l) selects the the current line.
  9. close a file (ctrl + w) closes the current file.
  10. Global search (ctrl + shift + f) performs a global search amongst all the files.
  11. Add multiple cursor (alt + mouse-click) it's possible add multiple cursors just clicking with the mouse holding the alt key.
  12. Command palette (ctrl + shift + p) this is mandatory, with this shortcuts you can interact with the build-in features in VScode.