Topic 3D: Emmet: Commands
Master Advanced Emmet Commands for Efficient Development
Emmet offers powerful commands beyond simple HTML expansion that can significantly speed up your development workflow.
Access Emmet Commands
Open Command Palette
Use Cmd+Shift+P on Mac or Ctrl+Shift+P on Windows to access all available commands
Search for Emmet
Type 'Emmet' to filter and view all available Emmet features with their keyboard shortcuts
Setting Custom Keyboard Shortcuts
Access Keyboard Shortcuts
Mac: Code > Preferences > Keyboard Shortcuts. Windows: File > Preferences > Keyboard Shortcuts
Search Feature
Type the feature name or 'Emmet' to see all available Emmet commands
Assign Keystroke
Double-click the desired feature, press your preferred key combination, then hit Return
Visual Studio Code will warn you if other features are already using your chosen keystroke combination.
Wrap with Abbreviation Use Cases
Container Wrapping
Quickly wrap selected content with div containers using abbreviations like .container or .wrapper for instant styling structure.
Semantic Elements
Wrap content with semantic HTML5 elements like section, article, or header using simple abbreviations for better document structure.
Complex Structures
Create nested structures with classes and IDs in one operation, such as .card>.card-body>h3 for component layouts.
Using Wrap with Abbreviation
Select Content
Highlight the code you want to wrap, selecting from start to end without extra whitespace
Trigger Command
Use Option+W on Mac or Alt+W on Windows to open the abbreviation panel
Enter Abbreviation
Type your abbreviation and see the preview, then press Return to apply or Esc to cancel
Remove Tag Command Benefits
Emmet can automatically read image files and add correct width and height attributes, eliminating manual measurement and reducing layout shift.
Image Size Update Requirements
Click anywhere inside the img element you want to update
The src attribute must point to an accessible image file
Works best on img tags without width/height or with wrong values
Key Takeaways