Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 40 ยท Customization and Productivity

Productivity Workflows

Work faster in VS Code with multi-cursor editing, Emmet, multi-root workspaces, Zen mode, split editors and a daily routine for common tasks.

Speed in an editor does not come from knowing every feature. It comes from a small set of habits you use without thinking. This lesson gathers workflows that save the most time and shows how to combine them: moving without the mouse, editing many places at once, expanding abbreviations, keeping several folders in one window and removing distractions when you need to focus.

The runnable examples are stand-ins in JavaScript: an Emmet-like expander and a multi-cursor rename model. They illustrate the ideas but are not the editor's implementation.

Move without the mouse

  • Quick Open: Ctrl+P opens a file by typing part of its name. Type :42 after a name to jump to line 42, or @ to jump to a symbol in the file.
  • Command Palette: Ctrl+Shift+P runs any command by name.
  • Go to Symbol in file: Ctrl+Shift+O. Workspace symbol: Ctrl+T.
  • Go to line: Ctrl+G.
  • Switch editors: Ctrl+Tab, or Ctrl+1, Ctrl+2 to focus editor groups.
  • Toggle sidebar: Ctrl+B. Toggle panel: Ctrl+J.
  • Navigate back and forward: Alt+Left, Alt+Right return to where you were.

Edit many places at once

  • Add cursors by clicking: Alt+Click.
  • Add the next match: Ctrl+D selects the word and then each next occurrence; type to change them all at once. Ctrl+K Ctrl+D skips one.
  • Select all matches: Ctrl+Shift+L.
  • Cursor above or below: Ctrl+Alt+Up or Ctrl+Alt+Down.
  • Column (box) selection: Shift+Alt while dragging.
  • Rename a symbol properly: F2. It uses the language server, so it renames only real references and works across files. For plain text patterns use Replace in the Find widget (Ctrl+H), with regular expressions switched on when you need capture groups.
  • Move or copy lines: Alt+Up/Down, Shift+Alt+Up/Down.
  • Delete line: Ctrl+Shift+K. Insert line below: Ctrl+Enter.
  • Comment line: Ctrl+/. Block comment: Shift+Alt+A.
  • Expand/shrink selection: Shift+Alt+Right, Shift+Alt+Left.

A good beginner exercise is to rename a variable in a short file three ways: with F2, with Ctrl+D, and with Find and Replace. Compare which is safest.

Emmet

Emmet is built into VS Code for HTML and CSS. You type an abbreviation and press Tab (or Enter in the suggestion list) to expand it.

Abbreviation Expands to
! A full HTML5 document
ul>li*3 A list with three items
div.card>h2.title+p A div with class card, containing a heading and a paragraph
a[href=#] An anchor with an attribute
li.item$*3 Three items with classes item1 to item3
m10, p20-30 (in CSS) margin: 10px; and padding: 20px 30px;

Use > for child, + for sibling, * for repeat, . for class, # for id, [] for attributes, {} for text and $ for a counter. Wrap selected text with Emmet: Wrap with Abbreviation. To use Emmet in other file types (React JSX, for example) set emmet.includeLanguages.

Workspaces and multi-root

A folder opened in VS Code is a workspace. When one project spans several folders (a front end and a back end in separate repositories), use a multi-root workspace: File > Add Folder to Workspace..., then Save Workspace As... creates a .code-workspace file:

JSON
{
  "folders": [
    { "path": "web", "name": "Web" },
    { "path": "api", "name": "API" }
  ],
  "settings": { "editor.formatOnSave": true }
}

Each folder can still have its own .vscode files. The Explorer shows both roots; search covers all of them; the terminal asks which folder to start in. Commit a .code-workspace file if the team shares the layout.

Split editors and focus

  • Split editor: Ctrl+\. Drag a tab to a side to split. Two files side by side are ideal for a test and its source.
  • Pin a tab: Ctrl+K Shift+Enter, so it is not replaced by previews. Single-click opens a preview tab (italic), and double-click makes it permanent.
  • Zen Mode: Ctrl+K Z hides everything except the editor; Esc Esc exits.
  • Centered layout and Toggle Word Wrap (Alt+Z) help with prose and long lines.
  • Breadcrumbs at the top of the editor show where you are and let you jump to symbols.
  • Sticky scroll pins the current function or class header at the top.
  • Outline and Timeline sections of the Explorer give structure and history for the open file.

Search effectively

Ctrl+Shift+F searches all files. Switch on regular expression and match case with the buttons or Alt+R and Alt+C. Narrow with files to include (src/**/*.ts) and files to exclude. Search Editor (Search: Open New Search Editor) shows results as a document you can keep. Use search.exclude to skip generated folders so results stay relevant.

A daily routine

  1. Open the project folder, check the branch in the status bar.
  2. Run the tests in a named terminal in watch mode.
  3. Navigate with Ctrl+P and Ctrl+Shift+O, never by scrolling the tree.
  4. Fix problems from the Problems panel (F8 moves to the next one).
  5. Review changes in Source Control before every commit.

Runnable stand-ins

JS Stand-in: a tiny Emmet expander

Press Run (or Ctrl + Enter) to see the console output here.

No output.

JS Stand-in: multi-cursor rename

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which shortcut selects the next occurrence of the current word for multi-cursor editing?

    Ctrl+D adds the next match to the selection. Ctrl+Shift+L selects all matches.
  2. 2. What does the Emmet abbreviation ul>li*3 produce?

    means child and *3 repeats the li three times inside the ul.

  3. 3. Why use a multi-root workspace?

    A .code-workspace file lists several folders that open together.
  4. 4. What is the safest way to rename a function used across files?

    Rename Symbol uses the language server so only real references change.

Summary

  • Move with Ctrl+P, Ctrl+Shift+O, Ctrl+G and the Command Palette instead of the mouse.
  • Multi-cursor (Ctrl+D, Ctrl+Shift+L, Alt+Click) edits many places at once; F2 renames safely.
  • Emmet expands abbreviations like ul>li*3 in HTML and CSS.
  • Multi-root workspaces keep related folders together in a .code-workspace file.
  • Split editors, Zen mode, breadcrumbs and a routine reduce friction.

Next: Project: Set Up a Node.js Workspace