← XeFM crftwr/xefm on GitHub · craftware

Text Viewer

XeFM has a built-in text viewer for source code, config files, logs, and any other text. The encoding is detected automatically — UTF-8 with or without BOM, Shift-JIS, EUC-JP, ISO-2022-JP, Latin-1 / CP1252 and more, with a manual override through change_encoding (see Text Encodings). Put the cursor on a file and run view_file (or open_item on a file with no other enter rule) to open it full-window, without leaving XeFM. Binary files are detected and show a short placeholder instead of mojibake.

For file types with a richer renderer — Markdown especially — the viewer can switch between the rendered view and the plain source (see below and Markdown Viewer).

Opening & controls

The viewer draws its own keys along the bottom, and F1 inside it lists them all — both read from your KEY_BINDINGS, so they are right whatever you have bound.

Action What it does
view_file View the focused file in the text viewer
open_item Same, for a file with no other enter rule
↑ ↓ PgUp PgDn Home End Scroll by line, page, or to either end
← → Scroll horizontally (when line wrap is off)
toggle_wrap Toggle line wrapping
isearch Incremental search — then ↑ / ↓ step between matches
toggle_view_mode Toggle rendered / raw view (Markdown and other rich types)
change_encoding Choose the text encoding (Auto / explicit)
edit_file Edit the viewed file in the configured editor
Cmd/Ctrl + C Copy the current selection
Cmd/Ctrl + A Select the whole file
F1 Key help
quit / Esc Close the viewer

The view/edit keys are rebindable in your config’s KEY_BINDINGS; the arrow / page / home / end scroll keys are viewer-local and always active.

Tabs & syntax highlighting

Selecting text & copying

You can select text with the mouse and copy it to the clipboard.

Gesture Selects
Click & drag An arbitrary range from where you press to where you release
Double-click The whole word under the pointer
Triple-click The whole line under the pointer
Drag after a double / triple click Extends by whole words / lines
Shift-click Extends the current selection to the click
Cmd/Ctrl + A Selects the entire document

The highlighted range tracks the pointer as you drag, and the selection survives scrolling — scroll away and back and it is still there.

To select more than one screenful, drag past the top or bottom of the text and hold there: the view keeps scrolling under the pointer and the selection grows with it, faster the further out you hold. Drag back inside, or release, and it stops.

Press Cmd+C (macOS) or Ctrl+C (Linux / Windows) to copy. The text viewer copies the selected source text exactly, each display line on its own line.

On a terminal

Whether the copy reaches your system clipboard depends on the terminal supporting the OSC 52 clipboard escape (most modern terminals do). The copy always works for pasting back inside XeFM regardless.

Rich copy from the Markdown view

When you copy from the rendered Markdown view (toggle_view_mode on a .md file), the copy carries rich formatting — bold, italics, inline code, links, headings and tables come across intact when you paste into a formatting-aware app, while a plain editor gets the plain text. See Markdown Viewer for the details.

See also