code editing

While the agent handles complex tasks, you can also edit code directly in twig. This page covers the built-in editor features.

editor basics

Twig's editor is built on CodeMirror, providing a fast and capable editing experience.

opening files

  • from the sidebar - click any file in the file tree
  • quick open - use cmd + p and type the filename
  • from the agent - click file links in agent responses

tabs

Multiple files open as tabs at the top of the editor:

  • Click a tab to switch files
  • Middle-click or click the X to close
  • Drag tabs to reorder
  • Right-click for more options (close others, close all)

saving

  • auto-save - changes save automatically after a brief pause
  • manual save - cmd + s to save immediately
  • unsaved indicator - a dot appears on tabs with unsaved changes

editing features

syntax highlighting

Twig recognizes common languages and file types:

  • JavaScript / TypeScript
  • Python
  • HTML / CSS
  • JSON / YAML
  • Markdown
  • And many more

line numbers

Line numbers appear in the left gutter. Click a number to select the entire line.

indentation

Twig detects and matches your project's indentation style:

  • Tab or spaces
  • Indentation width (2 spaces, 4 spaces, etc.)

Use tab to indent, shift+tab to outdent.

code folding

Collapse blocks of code to focus on what matters:

  • Click the arrow in the gutter to fold/unfold
  • cmd + shift + [ to fold
  • cmd + shift + ] to unfold

search and replace

find in file

cmd + f opens find in the current file:

  • Type to search
  • Use arrows or enter to move between matches
  • Press escape to close

replace

cmd + h opens find and replace:

  • Enter search term and replacement
  • Replace one at a time or all at once

find in project

cmd + shift + f searches across all files:

  • Results show in a panel
  • Click a result to jump to that location
  • Use filters to narrow by file type or folder

multiple cursors

Edit multiple locations simultaneously:

  • add cursor - cmd + click to add cursors
  • select next occurrence - cmd + d to select next match
  • select all occurrences - cmd + shift + l to select all matches

Type, delete, or paste - the action applies to all cursor locations.

keyboard shortcuts

Common editing shortcuts:

actionshortcut
savecmd + s
undocmd + z
redocmd + shift + z
cut linecmd + x (with nothing selected)
copy linecmd + c (with nothing selected)
move line upopt + up
move line downopt + down
duplicate linecmd + shift + d
delete linecmd + shift + k
toggle commentcmd + /

working with the agent

The editor and agent work together:

  • agent edits appear in the editor when approved
  • click code in chat to see it in context
  • select code and ask the agent about it
  • point the agent to specific lines when describing tasks