Topic 2C: VS Code: Useful Coding Features & Keystrokes
Master VS Code with Essential Keyboard Shortcuts
Microsoft provides comprehensive illustrated guides and official keyboard reference sheets to help you master VS Code efficiently.
Official Keyboard Reference Resources
Mac Users
Download the official Mac keyboard shortcuts PDF from Microsoft. Contains comprehensive shortcut mappings for macOS.
Windows Users
Access the Windows-specific keyboard reference sheet. Includes all essential shortcuts optimized for Windows systems.
Comment Types in VS Code
| Feature | Line Comment | Block Comment |
|---|---|---|
| Mac Shortcut | Cmd + / | Option + Shift + A |
| Windows Shortcut | Ctrl + / | Alt + Shift + A |
| Selection Required | No - cursor anywhere | Yes - select text |
| Scope | Entire line | Selected portion |
Moving Code Lines
Position Cursor
Place cursor anywhere in the line you want to move, or select multiple lines
Execute Move
Use Option + Up/Down Arrow (Mac) or Alt + Up/Down Arrow (Windows)
Repeat as Needed
Continue pressing the key combination to move lines multiple positions
Efficient Line Operations
Position Cursor
Place cursor anywhere in the target line - no need to select the entire line
Cut or Copy
Use standard cut (Cmd/Ctrl + X) or copy (Cmd/Ctrl + C) shortcuts
Paste Destination
Navigate to target location and paste with Cmd/Ctrl + V
New Line Insertion Options
Insert Below Current Line
Cmd + Return (Mac) or Ctrl + Enter (Windows). Cursor stays at current position while new line appears below.
Insert Above Current Line
Cmd + Shift + Return (Mac) or Ctrl + Shift + Enter (Windows). Creates new line above without moving cursor to end.
Efficient Line Operations
Position Cursor
Place cursor anywhere in the target line - no need to select the entire line
Cut or Copy
Use standard cut (Cmd/Ctrl + X) or copy (Cmd/Ctrl + C) shortcuts
Paste Destination
Navigate to target location and paste with Cmd/Ctrl + V
Multi-Selection Workflow
Select Initial Text
Highlight the text pattern you want to find and modify
Add Next Occurrence
Press Cmd + D (Mac) or Ctrl + D (Windows) to select next matching text
Skip Unwanted Matches
Use Cmd/Ctrl + K followed by Cmd/Ctrl + D to skip selections you don't want
Edit Simultaneously
Type to modify all selected instances at once
Code Navigation Methods
Symbol Navigation
Use Cmd + Shift + O (Mac) or Ctrl + Shift + O (Windows) to jump to CSS selectors or JavaScript functions quickly.
Line Number Jump
Press Ctrl + G on both Mac and Windows to jump directly to any line number. Type the number and press Enter.
Word and Line Movement
Navigate efficiently with Option/Ctrl + Arrow keys for word jumping and Cmd/Home-End for line boundaries.
Code Folding Methods
| Feature | Method 1 | Method 2 |
|---|---|---|
| Mac Shortcut | Cmd + K then Cmd + L | Cmd + Option + [ or ] |
| Windows Shortcut | Ctrl + K then Ctrl + L | Ctrl + Shift + [ or ] |
| Action | Toggle fold/unfold | Specific fold/unfold |
| Ease of Use | Two-step process | Single keystroke |
Key Takeaways