# Edit text with F4 — built-in editor or your own

> F4 edits the file under the cursor in the built-in quick editor or your external editor. Saves keep encoding and line endings, never clobber, and are undoable.

- Canonical: https://cwdio.com/features/text-editor/
- Updated: 2026-08-15
- Product: Cwdio File Manager (cwdio) — https://cwdio.com

<kbd>F4</kbd> edits. That is the orthodox verb — Total Commander, Far, Midnight Commander — and in cwdio it
means one of two things: the **built-in quick editor**, which is Quick Look's edit mode, or the **external
editor** you already use. You pick the default once; the other is always one chord away.

## What it does

- **Built-in quick editor.** A CodeMirror 6 editor inside the Quick Look overlay: syntax highlighting per
  language, line numbers, bracket matching, multi-cursor, find/replace (<kbd>Ctrl+F</kbd>), go to line
  (<kbd>Ctrl+G</kbd>), history, optional word wrap. <kbd>F4</kbd> flips a preview into editing, <kbd>F3</kbd>
  flips back, <kbd>Ctrl+S</kbd> or <kbd>F2</kbd> saves. Loaded lazily, so it costs nothing until you use it.
- **External editor.** Detected installs, or a custom command. A **known** editor opens at the right line and
  column — VS Code family, Notepad++, Sublime, Zed — and a **folder** opens as a project in editors that take
  one. A **terminal editor** (`nvim`, `nano`, `micro`, `hx`…) runs in the embedded terminal, in the panel's
  folder, with `+line` where the editor understands it.
- **Byte-faithful, in-place saves.** The file's encoding, BOM, line endings and trailing newline are kept;
  the file is written in place. Before the write, the previous bytes are **copied into the overwrite
  stash**, so <kbd>Ctrl+Z</kbd> after a save restores the earlier version through the same undo as a move.
- **Refuses to clobber.** A save checks that the file has not changed since it was read and that it is
  writable; a conflict, a vanished file or a read-only attribute each raise a **banner with explicit actions**
  rather than failing silently or overwriting.
- **From a search hit.** <kbd>F4</kbd> on a content-search result opens the file at its first matching line.

## How to use it

1. Put the cursor on a text file and press <kbd>F4</kbd>. By default the built-in editor opens for a local
   text file up to 8 MiB; larger or binary files go to the external editor, and the notice offers it.
2. Edit, then <kbd>Ctrl+S</kbd>. The status line confirms *Saved*, with the encoding and EOL it kept.
3. Change your mind? <kbd>Ctrl+Z</kbd> in the panel restores the previous bytes.
4. <kbd>Shift+F4</kbd> asks for a name, creates the file and drops you straight into the editor.
5. Force the choice for one file: <kbd>Ctrl+E</kbd> is always the external editor, <kbd>Ctrl+Shift+F4</kbd>
   always the built-in one (Far's "force internal").

**Preferences ▸ Editor** holds the two decisions: *F4 opens* (built-in or external) and *External editor*
(default, each detected editor, or a custom command with arguments and an option to run it in the embedded
terminal).

## Where it works

| Target | Built-in (default) | External |
| --- | --- | --- |
| Local text file ≤ 8 MiB | Quick Look edit mode | Your editor, at the line |
| Larger or binary file | External editor (offered) | External editor |
| Folder | External editor opens the folder | same |
| `sftp://` / `ftp://` text | Edited **in place** through the provider | Terminal editor in the SSH shell |
| Inside an archive | Opens **read-only** | same |

The built-in editor also watches the file: an external change while the buffer is clean reloads silently,
like the file list does; with unsaved edits you get a *Reload / Keep editing* banner.

## What it deliberately does not do

- It does not run editors through a shell string. An external launch is argv-only, a `.cmd` shim is
  refused, and a bare command name is resolved on `PATH` — so a file name can never be interpreted as
  arguments.
- It does not silently reformat, re-encode or normalise. If a file has mixed line endings, the status line
  says so and the save keeps the dominant style.
- It does not save into archives, and it does not (yet) round-trip a remote file through a GUI editor via a
  temp copy; remote text goes to the built-in editor or a terminal editor instead.

## Related

- [Quick Look and preview](/features/quick-look-preview/) — the same overlay in view mode.
- [Undo and the safety net](/features/undo-and-safety-net/) — the stash a save's previous bytes go to.
- [Terminal sync](/features/terminal-sync/) — where a terminal editor runs.

## Frequently asked questions

**Which external editors does cwdio recognise?** On Windows it looks for VS Code and VS Code Insiders, Cursor, Zed, Notepad++, Sublime Text and Notepad in their usual install locations, and honours $VISUAL then $EDITOR the way git does. Any other editor can be set as a custom command with {file}, {line}, {col} and {dir} placeholders. Terminal editors — vim, nvim, nano, micro, helix, emacs and friends — run inside cwdio's embedded terminal.

**Will the built-in editor change my line endings or encoding?** No. A save re-encodes with the file's own encoding (UTF-8 with or without BOM, UTF-16 LE/BE), keeps its line-ending style and trailing-newline state, and writes in place so the file keeps its identity. The status line shows exactly what it read: Ln, Col, the encoding and CRLF or LF.

**What happens if the file changed on disk while I was editing?** The save refuses and a banner offers Overwrite, Reload from disk, or Keep editing. If the file changed while your buffer was still clean it simply reloads; if you had unsaved edits you are told and asked. A read-only file gets a Make writable and save option. A decision is never a toast you might miss.

**Can I edit a file on a server?** Yes. A text file on an SFTP or FTP panel opens in the built-in editor and is written back in place through the connection — no temporary copy to lose track of. If you prefer a terminal editor, it runs in the server's SSH shell against the remote path. Files inside an archive open read-only; extract to edit.
