Code

Code editor

Read and edit your project's code in a full editor with tabs, split views, breadcrumbs, language tools, blame and AI actions on any selection.

Code mode opens a full code editor on your project. It has the tools you expect from a desktop editor: completions, go to definition, rename, formatting, search and split views. Your edits run in the preview as soon as you save.

Code mode with the explorer on the left, a file open in the editor with its tabs, the breadcrumbs and the status bar.

What you can do

  • Open files in tabs, pin them and split the editor right or down. Your tabs come back after a reload.
  • Use completions, hover info, go to definition, type definition and implementations, rename and find references.
  • Peek at a definition or its references without leaving the file.
  • Go back and forward through the places you visited, and jump from one problem to the next.
  • See how many places use a function, a component or a type, right above its name.
  • Format a document, organize its imports, and apply quick fixes and refactors.
  • Filter and sort the symbols of a file in the Outline, which follows your cursor.
  • Ask the AI about a selection: add it to the chat, explain it or refactor it.
  • See who changed each line with blame.
  • Leave notes on lines while you work.
  • Compare a file with its last saved version.
  • Change the editor's font, theme, display and behavior, find any option with a search, and choose how files save on their own.

Open Code mode

Choose Code in the mode toggle at the top of the editor, or press C or Cmd/Ctrl + 2. The left side shows the views rail: Explorer, Search, Source Control, GitHub, Comments, Timeline, Outline, Packages, Environment and Settings. Choose a view again to collapse the sidebar.

To jump to the code of an element, select it on the canvas and choose Open in code in its toolbar.

Tabs and split views

  • Click a file in the explorer to open it in a preview tab, shown in italics: the next file you click takes its place. Edit the file or double-click its tab to keep it open. A dot marks unsaved changes.
  • Right-click a tab for Close, Close Others, Close to the right, Close saved, Close all, Keep open, Pin Tab, Open to the side, Copy path, Copy relative path, Reveal in explorer, Compare with saved and Reopen closed editor (Alt + Shift + T).
  • Your open tabs come back when you reload the project: the same files in the same order, the pinned ones, the preview tab and the file you were reading.
  • Drag a tab to change its place in the tab bar, or focus it and press Cmd/Ctrl + Shift + Left or Right. Pinned tabs stay first.
  • Use the tab bar buttons for Split Right (or Close Split) and More actions: Split Down, Pin Tab, Close file, Close all, Show Changes and more.
  • In a split view, each side has its own tabs. A file you pick in the explorer, the tab bar or Quick Open opens on the side you are working in, and the other side keeps its file. Click a side's code or one of its tabs to work there.
  • To show a file next to the one you are reading, right-click it in the explorer and choose Open to the Side, or right-click its tab and choose Open to the side. Closing a tab on the second side only takes it off that side: the file stays open.
  • Drag the line between two editor groups to resize them.
  • Turn on Wrap Tabs in the editor settings to show every open tab on more rows instead of hiding the extra ones in a menu. Drag a tab onto any row to move it there.
  • Choose Full Screen (Ctrl + Cmd + F on a Mac) to give the editor the whole window. Press Esc to leave it.
A split view with a file on each side: the first side keeps its file while the second side shows the file opened to the side, with its own tabs and its close button.

Markdown files have Preview Markdown and Edit Markdown.

  • The breadcrumbs above the editor show the path of the file. Click a part to jump.
  • The Outline view lists the symbols of a TypeScript or JavaScript file (see below).
  • The status bar at the bottom shows the line and column (click it to Go to Line), the errors and warnings, the indentation, the language, and a shortcut to the Terminal.

Outline

The Outline view lists the functions, components, types and variables of the open file, nested the way the code is. Click a symbol to jump to it.

The Outline view with a filter field, the Outline options open on Sort by Position, Name or Kind and Follow cursor, and the symbol under the cursor highlighted.
  • Type in Filter symbols to keep only the symbols whose name matches, with their parents.
  • Open Outline options to sort by Position, Name or Kind, and to turn Follow cursor on or off.
  • With Follow cursor on, the symbol you are in is highlighted and its parents open as you move in the file.

Your choices are kept for the next time you open the project.

Work with the AI on a selection

Select code and a small bar appears:

  • Add to chat: attach the selection to your next message. You can also press Cmd/Ctrl + L.
  • Explain: ask the AI what the code does.
  • Refactor: ask the AI to improve the code and apply the change.
  • Copy.

The right-click menu

Right-click in the editor to open its menu. It lists what works for the language of the file:

The right-click menu of the code editor with Go to Definition, Go to Type Definition, Go to Implementations, Go to References, Peek, Rename Symbol, Refactor, Quick Fix, Organize Imports, Cut, Copy and Paste, each with its shortcut.
  • Go to Definition, Go to Type Definition, Go to Implementations and Go to References. A definition inside a library shows its types in a peek window, read-only.
  • Peek: see a definition, a type definition, the implementations or the references in a small window inside the file.
  • Rename Symbol, Change All Occurrences, Format Document and Format Selection.
  • Refactor, Quick Fix, Source Action and Organize Imports (TypeScript and JavaScript).
  • Expand Selection, Shrink Selection, Fold All, Unfold All, the indentation and Save Without Formatting.
  • Add Annotation: leave a note on the selected lines, or on the line of the cursor. See Annotate.
  • Run Selected Text in Terminal, when text is selected: the selection runs in the terminal. See Run code from the editor.
  • Cut, Copy and Paste, and the Command Palette.

The Rename Symbol box renames with Enter and closes with Esc.

Language tools

Use the right-click menu, the keys below, or the command palette in command mode (Cmd/Ctrl + Shift + P). On a Mac, the function keys act as media keys, so each of these actions also has a key that needs no Fn:

ActionShortcutOn a Mac
Go to DefinitionF12Ctrl + Shift + G
Go to Type DefinitionCtrl + Shift + YCtrl + Shift + Y
Go to ImplementationsCmd/Ctrl + F12Ctrl + Shift + I
Find All ReferencesShift + F12Ctrl + Shift + U
Peek DefinitionAlt + F12Ctrl + Shift + J
Peek ImplementationsCmd/Ctrl + Shift + F12Ctrl + Shift + X
Rename SymbolF2Ctrl + Shift + W
Change All OccurrencesCmd/Ctrl + F2Ctrl + Shift + L
Format DocumentShift + Alt + FShift + Alt + F
Format SelectionCmd/Ctrl + Shift + Alt + FCmd + Shift + Alt + F
Organize ImportsShift + Alt + OShift + Alt + O
RefactorCmd/Ctrl + Shift + RCtrl + Shift + R
Quick FixCmd/Ctrl + .Cmd + .
Source ActionCtrl + Shift + SCtrl + Shift + S
Command PaletteF1Ctrl + Shift + C
Expand Selection / Shrink SelectionShift + Alt + Right / Shift + Alt + Left
Go to Next Change / Go to Previous ChangeAlt + F5 / Shift + Alt + F5
Toggle BlameCmd/Ctrl + Shift + B
Go Back / Go ForwardAlt + Shift + - / Alt + Shift + =Ctrl + - / Ctrl + Shift + -
Go to Next Problem / Go to Previous ProblemF8 / Shift + F8Ctrl + Shift + . / Ctrl + Shift + ,

Go Back and Go Forward are also the arrows at the left of the breadcrumbs. In command mode, the palette lists the commands you used last under Recently Used. Toggle Column Selection, in the palette, makes a mouse drag select a block of columns: the status bar shows Column Selection while it is on, and a click on it turns it off.

In TypeScript and JavaScript files:

  • Code folds by its structure: the import block, functions, objects, JSX elements, comments and // #region blocks. Use the arrows next to the line numbers, Fold All or Unfold All.
  • Expand Selection grows the selection along the code: the word, the expression, the element, the block, then the whole file.
  • When you rename an opening JSX tag, its closing tag changes as you type.
  • Semantic Highlighting gives each name the color of what it is: a variable, a parameter, a function, a type or a property. It works with the Lyna and Dark Plus themes and is on by default.
  • Reference Counts Above Code shows above each function, component, class and type how many places use it, for example 3 references. Click the count to see them in a peek. It is off by default.
  • Refactor (Cmd/Ctrl + Shift + R, or the light bulb next to a selection) offers Extract to function, Extract to constant, Extract to type alias and Extract to interface, in the scope you pick, and Move to a new file for top-level code. After an extraction, the new name is ready to rename, and one undo puts the code back.
  • Inlay Hints, in the Language section of the settings, show parameter names, variable types and return types in grey, right in the code. They are off by default.

Blame, changes and line notes

  • Toggle Blame (Cmd/Ctrl + Shift + B) shows, next to each line, the commit that last changed it.
  • Lines you changed since your last staged version are marked in the editor. Click a mark to see that change under its lines, its old and new lines in one diff. Keep (Alt + Y) stages only that change for your next commit, and its mark goes away. Undo (Alt + N) puts the old lines back, and one undo brings your edit back. The arrows move to the previous and next change, Alt + F3 and Shift + Alt + F3 open the next and previous change from the cursor, and Esc closes it.
  • Point at a line and choose the + beside its number, or Cmd/Ctrl + click the line number, to leave a note on that line. To note several lines, select them, right-click and choose Add Annotation. The note is a thread your team sees between the lines, which follows the code as it changes, and Comments in the views rail lists every note by file. See Annotate.

When a file changes on disk

If the AI or a command changes a file you have open with unsaved edits, a File changed on disk banner appears. Choose Show diff, Keep mine or Use disk.

Editor settings

Open the Settings view to change how the editor looks and behaves. Every change applies at once. Type in the search field to find an option by its name, by one of its choices or by its usual term (for example code lens): only the sections that match stay open.

The Settings view with its search field, the Display section open with Render Whitespace, Sticky Scroll, Indent Guides, Smooth Scrolling and the minimap options, and Reset to Defaults at the bottom.
  • Color Theme: eight themes, light, dark and high contrast. Lyna Auto follows Lyna's mode: the editor is light when Lyna is light and dark when it is dark. Lyna Dark, Lyna Light and the other themes stay as you pick them, whatever Lyna's mode.
  • Editor: Font Size, Font Family, Line Height, Font Ligatures, Tab Size, Insert Spaces, Word Wrap, Line Numbers and Rulers. For rulers, type the columns separated by commas, for example 80, 120 (at most 4), then press Enter. Escape puts the saved columns back.
  • Display: Render Whitespace, Sticky Scroll (the first line of the function or block you are in stays at the top), Indent Guides, Smooth Scrolling, Minimap, Minimap Side and Minimap Characters.
  • Language: Inlay Hints, Semantic Highlighting and Reference Counts Above Code (see Language tools).
  • Diff: Ignore Whitespace Changes hides the lines whose only change is spacing, and Wrap Long Lines wraps them in the diff. The same two options are buttons beside every diff: a file compared with its saved version, a Source Control change, a local history comparison and a commit opened from the branch graph.
  • Explorer: Compact Folders shows a chain of folders that each hold one folder on one row, and Hide Git Ignored Files hides what your .gitignore lists (see Explorer and search).
  • Behavior: Auto Save, Format On Save, Add Missing Imports On Save (adds the imports a TypeScript or JavaScript file uses and lacks, on by default), Organize Imports On Save (sorts the imports of a TypeScript or JavaScript file and removes the unused ones), Format On Paste, the trailing whitespace and final newline options, Bracket Colorization, Emmet, Auto Closing Brackets and Vim Keys (see Vim keys).
  • The last section sets the caret: its shape and how it blinks.

Reset to Defaults restores every option. Your keyboard shortcuts and snippets stay.

Auto save

Auto Save has three modes:

  • Off: you save with Cmd/Ctrl + S.
  • After a delay: a changed file saves when you stop typing for the Auto Save Delay (from 0.2 to 10 seconds). It saves the file you edited, even if you switched to another tab in the meantime. It writes your text as you typed it: formatting and the other save steps run at your next manual save.
  • When focus leaves the editor: a changed file saves when you click somewhere else (another panel, the chat, another window) or open another file in its place, with formatting and every save step.

What a save does

When you save a file, the editor tidies it in this order, each step only when its option is on:

  1. Add Missing Imports On Save adds the imports a TypeScript or JavaScript file uses but does not have. Only names your code really uses count: a word in a comment, a string or text on the page never does. A new import joins the existing line for its source, or goes on a new line after your imports, with the file's own quotes and semicolons. When a name could come from more than one place, the editor takes the usual one for a Lyna project, or else leaves the name out. A notice lists the imports added and the names left out. A save adds at most 10 imports and never waits more than 1.5 seconds for them. When the code engine is still starting and that time runs out, a notice says the imports were not checked: save again in a moment.
  2. Organize Imports On Save sorts the imports and removes the unused ones.
  3. Format On Save formats the file.
  4. The trailing whitespace and final newline options.
  5. The Tailwind CSS class fixes.

These steps never break your code. When they would leave errors that your text did not have, the editor saves your text as you typed it, shows it again in the editor, and a notice says the automatic changes were skipped.

You can keep typing while a file saves: no key is lost and nothing moves under the cursor. The save then keeps your text as it is, the steps run at your next save, and the tab shows unsaved changes for the keys you typed after.

Save Without Formatting (in the right-click menu and the command palette) saves exactly the text you typed, with none of these steps. When the editor fixes the Tailwind CSS classes of a file you open, that fix and its Undo also save the text exactly as it shows.

Keyboard shortcuts

Keyboard Shortcuts lists every key of the code editor. It is the same list as the Code editor section of Settings > Account > Keyboard shortcuts: a change in one place shows in the other. Type in Search actions... to find an action or a key.

  • To change a key, click the keys of a row and press the new combination. It is saved at once. Escape cancels, and Delete removes the key.
  • A key needs Ctrl, Alt or Cmd, or is an F key: the editor also hears it while you type.
  • Keys the browser or your system keeps for its tabs and windows cannot be used, and the row says why. When another action already uses the key where the editor hears it, such as the command palette's Cmd + K, the row says which one: choose Replace to take the key, or Cancel.
  • The reset button gives an action its default keys back, and the remove button leaves it with no key. Cut, Copy and Paste are marked Fixed.

Your keys apply at once in every open editor, and are kept on this device. See Keyboard shortcuts.

Vim keys

Turn on Vim Keys in the Behavior section to edit with Vim's modes: normal, insert, visual and replace. The option is off by default and does not apply on a phone.

  • The status bar shows the current mode, for example -- INSERT --, and the keys of a command you have not finished, such as 2d.
  • Type : or / in normal mode: the command line opens in the status bar. Escape closes it.
  • Cmd/Ctrl + S, Quick Open and the command palette keep their keys.
  • Escape leaves insert, visual or replace mode. In normal mode it closes an open panel or menu, as it does without Vim.

Turn the option off to get the usual cursor back.

Snippets

Snippets holds your own snippets. Choose Add Snippet and fill in:

  • Name: what the suggestion shows.
  • Prefix: what you type to get it, with no spaces.
  • Language: where it is offered.
  • Body: the text it inserts. $1 and ${2:text} are the places Tab moves through, $0 is where the cursor ends, and \$ is a dollar sign.

Type the prefix in a file of that language: the snippet shows in the suggestions, after the language's own items. Edit or delete a snippet from its row; deleting asks first.

Language settings

Language Settings gives one language its own settings. Choose the Language (TypeScript and JavaScript, CSS, HTML, JSON or Markdown), then set its Tab Size, Insert Spaces, Word Wrap, Format On Save or Rulers. Each one reads Use the default until you change it, and the language picker shows how many settings a language has of its own.

The Language Settings section of the Settings view with TypeScript and JavaScript picked, and Tab Size, Insert Spaces, Word Wrap, Format On Save and Rulers each on Use the default.

Every file of that language follows its settings at once, for example no word wrap in TypeScript or 4 spaces in CSS. As with the main Tab Size, a file that already uses its own indentation keeps it.

Plan availability

FreePro
Read and edit codeYesYes
Copy code from the editorNoYes
Copy Code and Download File in the tab barNoYes

To get all your code on Free, use Download code in the project menu. See Projects.

Shortcuts

ActionShortcut
Code modeC or Cmd/Ctrl + 2
SaveCmd/Ctrl + S
Go to fileCmd/Ctrl + P (add :line to jump to a line, start with @ or # for symbols)
Search the projectCmd/Ctrl + Shift + F
Command palette, command modeCmd/Ctrl + Shift + P
Find / Find and replace in the fileCmd/Ctrl + F / Cmd/Ctrl + Alt + F
Toggle commentCmd/Ctrl + /
Move line up / downAlt + Arrow Up / Alt + Arrow Down
Copy line up / downShift + Alt + Arrow Up / Shift + Alt + Arrow Down
Add the selection to the chatCmd/Ctrl + L
Full screenCtrl + Cmd + F on a Mac, Esc to leave
Reopen closed editorAlt + Shift + T
Show or hide the bottom panelCmd/Ctrl + J
Run the selected text in the terminalCmd/Ctrl + Alt + Enter

Press ? outside a text field to see every shortcut, including the full code editor list.

Need help?

Ask the team, read what changed, or learn from the blog.