Visual Studio (Code)

Shortcuts and QoL features

  • ctrl + T - search for a class. If you want to search for UserController.cs you can type UCont and it will find it
  • ctrl + shift + P - search inside Visual Studio options
  • ctrl + D - duplicate actual line
  • alt + ↑ / ↓ - move code lines

Auto-complete placeholders

  • prop - creates a new property for a class
  • ctor - creates a new constructor
  • cw - creates a new Console.WriteLine() statement
  • try - creates a try-catch statement

To create a new property, type prop, hit twice tab and it creates a property template which you can navegate and override

vstudio 2

Multi-caret and multi-cursor editing

(check this for more details)

For lines that are aligned

  • alt + mouse click - selects a block to edit
  • alt + shift + arrow - same with keyboard

For multiple places that are not aligned

  • ctrl + alt + mouse click - click where you want to add a caret
  • (select the word you want to match) alt + shift + ; - vstudio selects all locations that match selected text in the current document and you may edit them

    Debug in VsCode

    Watch a variable

    En la pestaña watch se puede introducir el nombre de una variable y al hacer debug mostrará siempre el valor de esta variable.

vstudio-4

Ocurre lo mismo al hacer click derecho sobre una variable en modo debug. Hay una opción Quickwatch para añadir esa variable.

vstudio-5

Go back when debugging

Si te has pasado un breakpoint puedes volver a ejecutarlo arrastrando el punto de ejecucion actual (la linea donde estas actualmente) hasta donde la quieres

vstudio-6

Conditional breakpoints

You may also set conditional breakpoints with right click when setting a breakpoint.

vstudio-7