Free — no signup required

Snippets and Productivity Shortcuts

3 min read

Never Type Boilerplate Again

A snippet is a template that expands from a short keyword. You type tf-resource, press Tab, and VS Code inserts a full Terraform resource block with your cursor positioned at the first field you need to fill in. Snippets eliminate the cognitive overhead of remembering boilerplate syntax and the mechanical overhead of typing it.

Creating User Snippets

Go to File > Preferences > Configure User Snippets. You can create snippets that apply globally or only for a specific language (e.g., only in .tf files, only in .py files).

Snippet syntax uses a JSON format with a few special tokens:

  • ${1:placeholder} — a tab stop. The cursor jumps here first. The text after : is the default value.
  • ${2:placeholder} — the second tab stop. Press Tab again to jump here.
  • $0 — the final cursor position after all tab stops are visited.

A Terraform resource snippet, for example, expands a short prefix into a full resource "type" "name" { } block with the type, name, and body each defined as a separate tab stop — so typing the prefix and pressing Tab repeatedly walks the cursor through exactly the fields that need filling in, in order.

A Python script header snippet is a good second example: a single prefix expands into the full shebang line, module docstring placeholder, standard import block, logging setup, and a main()/if __name__ == "__main__" skeleton — everything a real ops script boilerplate needs before the actual logic begins, with the cursor landing directly in the docstring and then the function body as you tab through it.

Essential Keyboard Shortcuts

These three shortcuts have the highest return on investment. Learn them first.

1. Command Palette — Ctrl/Cmd + Shift + P

The search bar for every VS Code action. Instead of hunting through menus, open the palette and type what you want: "Format Document", "Rename Symbol", "Toggle Word Wrap", "Open Settings". If VS Code can do it, the Command Palette can find it.

2. Quick Open — Ctrl/Cmd + P

Opens a file by name. Type a partial filename and VS Code fuzzy-matches across your entire project. Faster than clicking through the file tree for any project with more than a handful of files. You can also type @ to jump to a symbol (function, class) within the current file, or : followed by a number to jump to a specific line.

3. Multi-Cursor Editing

Multi-cursor editing lets you place multiple cursors in the document and type on all of them simultaneously. It is the fastest way to make the same structural change to multiple lines.

  • Alt + Click (Windows/Linux) or Option + Click (Mac): Places an additional cursor wherever you click. Click on 8 different lines, then type — all 8 lines receive your input simultaneously.
  • Ctrl/Cmd + D: Selects the current word. Press again to select the next occurrence of that word and add a cursor there. Repeat to select all occurrences. Then type to replace all of them at once.
  • Ctrl/Cmd + Shift + L: Selects all occurrences of the current word in the file at once.
  • Alt + Shift + Down/Up (Windows/Linux) or Option + Shift + Down/Up (Mac): Duplicates the current line downward or upward.
Interview Tip

Some interviewers ask about your approach to reducing toil in day-to-day engineering work. Multi-cursor editing, snippets, and the Command Palette are legitimate answers — they demonstrate that you think about efficiency at every level, not just at the infrastructure level. A concrete example: "When I need to rename a variable across a local block, I use Ctrl+D to select all occurrences and rename them simultaneously, rather than using Find and Replace, which requires more keystrokes and a context switch."

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free