Skip to content

Instantly share code, notes, and snippets.

@jerkovicl
Last active March 8, 2016 08:34
Show Gist options
  • Save jerkovicl/1f0fa8d5430b8687e435 to your computer and use it in GitHub Desktop.
Save jerkovicl/1f0fa8d5430b8687e435 to your computer and use it in GitHub Desktop.
VS Code tips & tricks
  • Code completion: just start typing and you will be offered anything that matches the syntax of the file’s language. (If not, press Ctrl + Space)
  • Go to definition: quickly find any definition with “F12″ (depending on language). If you press Ctrl and hover over a an object, you can get a preview of its declaration so that you will not need to jump anywhere.
  • Multiple selection and cursors: select all occurrences of any word with “Alt + Left Click.” You can add a cursor at the end of each line with “Ctrl + Shift + L,” allowing you to edit all occurrences of an object or symbol at once.
  • Peek editor: you must not switch context; you can have a “sneak-peek” with “Ctrl + Shift + f10.”
  • Format code: format your document with Shift+Alt+F
  • Command file args: open file code mynewfile.js, open folders code c:\myfolder1 c:\myfolder2 c:\myapp\program.cs, start new editor session code -n (--new-window)
  • Shift+Alt+Left Shift+Alt+Right shrink/expand selection

######Multi-cursor

  • Ctrl+D selects the word at the cursor, or the next occurrence of the current selection.
  • Ctrl+K Ctrl+D moves the last added cursor to next occurrence of the current selection. The two actions pick up the matchCase and matchWholeWord settings of the find widget.
  • Ctrl+U undoes the last cursor action, so if you added one cursor too many or made a mistake, press Ctrl+U to return to the previous cursor state.
  • Insert cursor above Ctrl+Alt+Up and insert cursor below Ctrl+Alt+Down now reveals the last added cursor, making it easier to work with multi-cursors spanning more than one screen height (i.e., working with 300 lines while only 80 fit in the screen).

######Comments actions

  • Ctrl+K Ctrl+C now forces adding line comments.
  • Ctrl+K Ctrl+U now forces uncommenting lines. (If multiple lines are selected, and not all of them have a line comment, the line comments will still be removed).
  • Ctrl+/ toggles line comment as before, but now inserts the line comment tokens aligned with the indentation of the selected code. It also will leave empty or whitespace-only lines untouched. Ctrl+/ is also more forgiving with regards to selection state when toggling comments in languages which only support block comments, such as CSS or HTML. Toggle block comment Shift+Alt+A is also more forgiving related to selection state when toggling block comments.

######Problem Matchers

  • $jshint-stylish: To detect jshint problems produced by the stylish reporter.
  • $eshint-compact: To detect eslint problems produced by the compact reporter.
  • $eslint-stylish: To detect eslint problems produced by the stylish reporter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment