[← README](../../README.md) · [Docs index](../README.md) · [The preview pane](README.md) # Text and code Source code, config files and plain text show highlighted in the current theme's colours; Markdown shows rendered, with Mermaid diagrams and typeset math; a file git sees as changed can show its diff. Use it to read a file without opening an editor. ![Four previews: a calendar, the git diff of main.rs with removed lines red and added lines green, a log file coloured by level, and the first chapter of an EPUB book](../screenshots/gui-previews-more.png) *main.rs with **Diff** on, and launch.log with its WARN and ERROR lines coloured.* ## Contents - [How to use it](#how-to-use-it) - [Formats](#formats) - [Languages](#languages) - [Markdown](#markdown) - [The git diff](#the-git-diff) - [What you see](#what-you-see) - [Settings and config.toml](#settings-and-configtoml) - [In the terminal app](#in-the-terminal-app) - [Questions](#questions) ## How to use it 1. Put the cursor on the file and press **Space** or **F3** to open the pane. 2. For Markdown, choose **Rendered** or **Source** at the top right. 3. For a file git shows as changed (a coloured git glyph in the panel), choose **File** or **Diff**. 4. **Enter** opens the file in its program, **F4** in your editor. | Key | Desktop app | Terminal app | |---|---|---| | **Space** / **F3** | Shows or hides the pane | **F3** opens the file in the [built-in viewer](../commands/view-and-edit.md#the-built-in-viewer), full screen | | **F4** | Opens the file in your editor | The same | | **Enter** | Opens the file in its program | The same | ## Formats | Files | Preview | |---|---| | Source code, config, plain text | Highlighted by [highlight.js](https://highlightjs.org/): all of its 190-odd languages, and five more grammars for what it lacks (COBOL, Zig, Svelte, Terraform/HCL, Solidity). See [Languages](#languages). Colours come from the theme, so every [theme](../customise/themes.md) matches | | `.log`, JSON Lines, and any text over 512 KB | The log view: every line, read a screen at a time, a log coloured by level, followed, filtered, its fields as columns. See [Logs](logs.md) | | Binary files | A hex dump: offset, 16 bytes in hex, and the printable characters. A local model (`.gguf`, `.safetensors`, `.pt` …) shows its facts instead ([Your local models](../files/local-models.md#the-facts)) | | Encodings | UTF-8 (with or without a byte order mark), UTF-16 with its byte order mark, and anything else read as Windows-1252 (Latin-1 with Windows's curly quotes, dashes and €), so a file from an old Windows machine keeps its accented letters | | `.md`, `.markdown` | Rendered by [marked](https://marked.js.org/); ```` ```mermaid ```` blocks drawn as diagrams by [Mermaid](https://mermaid.js.org/); `$…$`, `$$…$$`, `\(…\)` and `\[…\]` typeset by [KaTeX](https://katex.org/) | A file counts as binary when its first 8 KB hold a zero byte (UTF-16, which has one in nearly every character, is told apart by its byte order mark). Anything the app has no special view for is shown as text or hex, so every file has a preview. ### Languages The language is picked the same way in both apps, by one table in `coxswain-core` (`code::language`): 1. **The whole name**: `Makefile`, `Dockerfile`, `CMakeLists.txt`, `Gemfile`, `PKGBUILD`, `.bashrc`, `.vimrc`, `nginx.conf` … 2. **The extension**. Old ones are known too: | Language | Extensions | |---|---| | COBOL | `.cob` `.cbl` `.cpy` | | Fortran | `.f` `.for` `.f77` `.f90` `.f95` `.f03` `.f08` | | Pascal and Delphi | `.pas` `.pp` `.dpr` `.dpk` `.lpr` | | BASIC, QuickBASIC, Visual Basic | `.bas` `.bi` `.vb` `.vbs` | | Assembly (x86, ARM, MIPS) | `.asm` `.nasm` `.s` `.inc` | | DOS batch | `.bat` `.cmd` | | Modula-2 | `.mod` `.def` (with Pascal's colours: highlight.js has no Modula-2) | | Lisp, Scheme | `.lisp` `.lsp` `.cl` `.el`, `.scm` `.ss` `.rkt` | | Erlang, Elixir, Haskell, OCaml, F# | `.erl` `.ex` `.exs` `.hs` `.ml` `.fs` `.fsx` | | Prolog, Smalltalk, Tcl | `.pro` `.pl`, `.st`, `.tcl` | | VHDL, Verilog, SystemVerilog, Coq | `.vhd` `.vhdl`, `.v` `.sv` | | AppleScript, AutoHotkey | `.applescript`, `.ahk` | 3. **What the file says**, where two languages share an extension: `.mod` is Modula-2 when it holds `MODULE` (a tracker module is binary and shows as hex); `.pro` is Prolog unless it reads like a Qt project; `.v` is Coq when it has `Theorem`, `Proof.` or `Require Import`, else Verilog; `.s` is ARM, MIPS or x86 assembly by its registers; `.inc` is PHP, Pascal or assembly; `.m` Objective-C or MATLAB; `.pl` Perl or Prolog; `.pp` Pascal or Puppet; `.fs` F# or a GLSL shader; `.bas` line-numbered BASIC or Visual Basic. 4. **The first line**: `#!/usr/bin/env python3`, `#!/bin/sh`, `