Editing Basics

Master fundamental text editing techniques in Zed

The Zed Editing Philosophy

Zed's editing capabilities combine the best features from modern editors with unique optimizations:

  • Performance: Native implementation provides instant response
  • Precision: Powerful selection and manipulation tools
  • Intelligence: Context-aware completions and suggestions
  • Flexibility: Customizable to match your workflow

Zed uses Tree-sitter for parsing and understanding your code, enabling more accurate syntax highlighting and smarter editing operations.

Text Selection

Text Selection in Zed

Basic Selection

Zed offers several ways to select text:

  • Mouse Selection: Click and drag to select text
  • Keyboard Selection: Hold Shift while using arrow keys
  • Word Selection: Double-click a word or use to select by word
  • Line Selection: Triple-click a line or use L to select the current line

Smart Selection

Zed understands code structure and offers smart selections:

  • Expand Selection: ShiftA expands selection to encompass logical code units
  • Select to Bracket: ShiftM selects content between matching brackets
  • Select All Occurrences: ShiftL selects all instances of the current selection

Use Esc to cancel a selection and return to a single cursor.

Multiple Cursors

One of Zed's most powerful features is the ability to edit in multiple places simultaneously:

Creating Multiple Cursors

  • Manual Placement: + Click to place additional cursors
  • Column Selection: Shift + drag to select a rectangular region
  • Add Cursor Above/Below: or

Selection-based Cursors

  • Select Next Occurrence: D adds a cursor at the next instance of your current selection
  • Select All Occurrences: ShiftL places a cursor at every instance of your selection
Multiple Cursors

Multiple cursors work with nearly all editing operations, including typing, deletion, selection expansion, and clipboard operations.

Common Use Cases

  1. Rename Multiple Variables

    Select a variable, press ShiftL to select all occurrences, then type to replace them all.

  2. Add Text to Multiple Lines

    Use to add cursors to adjacent lines, then type or edit.

  3. Convert Data Formats

    Use column selection to transform columns of data between formats.

Text Manipulation

Basic Editing

  • Cut, Copy, Paste: Standard X, C, V
  • Delete Line: ShiftK
  • Duplicate Line: ShiftD
  • Join Lines: J

Moving Text

  • Move Line Up/Down: or
  • Indent/Outdent: Tab or ShiftTab

Transformations

  • Convert to Uppercase: ShiftP then type "Transform to Uppercase"
  • Convert to Lowercase: ShiftP then type "Transform to Lowercase"

Find and Replace

Basic Find

Press F to open the find dialog:

  • Type your search term
  • Use Enter to find the next occurrence
  • Use ShiftEnter to find the previous occurrence
Find Dialog

Find and Replace

Press F to open the replace dialog:

  • Enter search term and replacement text
  • Use "Replace" to replace the current match
  • Use "Replace All" to replace all matches

Search Options

  • Case Sensitivity: Toggle case-sensitive search
  • Whole Word: Match only complete words
  • Regular Expressions: Use regex patterns for advanced searching

For project-wide search, use ShiftF to search across all files.

Code Folding

Code folding allows you to collapse sections of code to focus on specific parts:

Fold Operations

  • Fold Current Block: [
  • Unfold Current Block: ]
  • Fold All: K 0
  • Unfold All: K J
Code Folding

Auto-Completion and Snippets

Auto-Completion

Zed provides intelligent code completion as you type:

  • Completion suggestions appear automatically
  • Use Tab or Enter to accept suggestions
  • Use arrow keys to navigate between suggestions
  • Press Esc to dismiss suggestions
Auto-Completion

Code Snippets

Snippets are pre-defined code templates that can be quickly inserted:

  • Type the snippet prefix and select from the suggestions
  • Use Tab to navigate between snippet placeholder fields
  • Edit placeholder values to customize the snippet

Language servers provide context-aware completions based on your codebase, imported libraries, and standard language features.

Formatting and Indentation

Auto-Indentation

Zed automatically indents your code based on language rules:

  • Press Enter to create a new line with proper indentation
  • Opening braces or brackets automatically indent the next line
  • Closing braces or brackets match the indentation of their opening pair

Manual Formatting

  • Format Selection: K F
  • Format Document: ShiftI

Enable "Format on Save" in settings to automatically format your code whenever you save a file.

Whitespace and Indentation Settings

Customize indentation settings for your preferences:

  • Tab Size: Set the width of tab characters
  • Insert Spaces: Use spaces instead of tab characters
  • Detect Indentation: Automatically match the file's existing indentation style

What's Next?

Now that you've learned the basic editing features in Zed, you're ready to explore more advanced navigation techniques that will help you move around your code efficiently.