Chapter 3: Modal Editor and Panels

Both autodoc --ui (the terminal TUI) and autodoc --gui (the native desktop application) show the same thing: one page, 120 columns wide and centred, and panels that open over it from its sides. The page edits in one of two editor modes, Vim (modal, the default) or Text (modeless). Every open file is a buffer, and the leader key, SPC, reaches the rest.


3.1 The Page

The screen is a page and nothing else: the file, 120 columns wide and centred, the ruler at its right edge. With no file open, the page is an untitled draft: type into it (i), and Ctrl+S names and saves it as a file. Everything else comes when it is asked for:

The page wraps long lines at its width, and can number its lines in a dimmed gutter: View › Wrap long lines and Line numbers, or Preferences. Preferences sets the page's width too. ? in Normal mode shows the Vim keys in a card at the bottom right; the page keeps the keyboard, and ? again closes it.

AutoDoc's Leader Keys on SPC's Card, by Group01234567Leader keysFindWindowPanelsFileManageHelpAgentsGroup on SPC's card

The chart counts the keys SPC's card lists (§3.4), as tui/keys.go binds them.


3.2 The Editor Modes: Vim and Text

The page edits in the Vim mode (modal, the default) or the Text mode (modeless). SPC k switches between them, and so does Options › Editor mode. In the Text mode, Ctrl+Space is the leader, so the switch is Ctrl+Space k. The choice is a preference the daemon keeps, so --ui and --gui share it.

stateDiagram-v2
    [*] --> Normal: Vim mode (the default)

    state "Normal (motions, operators, SPC)" as Normal
    state "Insert (typing)" as Insert
    state "Visual (character, line, block)" as Visual
    state "Command line (:w :q :find :b ...)" as Command
    state "Picker (SPC o, SPC /, SPC b s)" as Picker
    state "Text mode (modeless)" as Text
    state "Rendered View (Ctrl+T, --gui)" as RenderedView

    Normal --> Insert: i / a / I / A / o / O
    Insert --> Normal: Esc
    Normal --> Visual: v / V / Ctrl+v
    Visual --> Normal: Esc / y / d / c / > / <
    Normal --> Command: : or Ctrl+;
    Command --> Normal: Enter / Esc
    Normal --> Picker: SPC o / SPC SPC / SPC b s
    Picker --> Normal: Enter (open) / Esc
    Normal --> Text: SPC k
    Text --> Normal: Ctrl+Space k
    Normal --> RenderedView: Ctrl+T
    RenderedView --> Normal: Ctrl+T

The Vim mode

  1. Normal:
    • motions: h j k l, w b e, 0 $, gg G, and { } by paragraph ([ and ] move by paragraph too);
    • operators: d, c, y, >, <, and g~ gu gU;
    • text objects: iw aw, iW aW, i" i', i`, i( (ib), i{ (iB), i[, i<, ip (a paragraph) and is (a sentence);
    • . repeats the last change;
    • H and L show the buffer before or after the shown one;
    • Ctrl+O and Ctrl+I step back and forward along the jumps, across documents too;
    • ? shows the Vim keys' card.
  2. Insert: entered with i, a, I, A, o or O; Esc goes back to Normal. In the GUI's Rendered View, Enter on a Markdown list item continues the list, and Tab / Shift+Tab nest the item or bring it out.
  3. Visual: character-wise v, line-wise V, or a block with Ctrl+v. > and < shift the lines selected.
  4. The command line: : opens it in Normal mode, and Ctrl+; opens it in either editor mode. Its commands are in §3.8.

The Text mode

Typing types. The keys are an ordinary text editor's:

Search › Find in page finds in the page.


3.3 Buffers

Every file opened is a buffer, and the GUI shows them as tabs. The status line (SPC t) shows [+] while the shown one has unsaved changes.

AutoDoc shows one page at a time: there are no window splits, and no folding. The panels (§3.5) and the GUI's HTML preview pane (SPC H) sit beside or over it.

Files anywhere

File › Open file… (SPC f) opens any file on this machine's disk in a file dialog with a preview; File › New file… (Ctrl+N, SPC n) makes one in any folder. A file inside a workspace's folder opens as that workspace's file. Any other is in no workspace: it edits, saves (a change on disk since it was read asks first), exports and reaches the plugins, but has no search, relations or frontmatter check, and the status line badges it [no workspace]. It stays open when the workspace changes. File › Open document… (SPC o) is the fast picker over the workspace's own files.

Files that open their own way


3.4 Leader (SPC) Chords and Command Pickers

In Normal mode, pressing the Spacebar (SPC) opens SPC's card, listing every leader key by group. A capital is the key with Shift (SPC O is Shift+O). The keys, as tui/keys.go and AutoDoc's features bind them:

Some keys work wherever the keyboard is: Ctrl+h/j/k/l move between the page and the panels (in Normal mode), Ctrl+S saves, Ctrl+G searches, Ctrl+W switches workspace (in the Vim mode's Insert, Ctrl+W deletes the word before the cursor: Esc first), F1 opens the help, F11 maximizes the terminal or the agents, and Ctrl+Q quits. Ctrl+Z never reaches a program in the terminal or the agents, so it can't stop one by accident.

The keys at a glance

Key Does
Space, Ctrl+Space the leader card (Space in Vim's Normal mode; Ctrl+Space in any editor mode): a key runs its command (e, l, /, o, O, d, H, k, ,, s …), listed by purpose: find and open, this file, the panels, the agents, help, managing, the window
Ctrl+G, SPC /, SPC SPC search the workspace, by words and meaning
/, n, N find a word in the pane with the keyboard (the page, the explorer, the links), then again forward and back (Normal mode)
SPC o, Ctrl+N, Ctrl+S open a document of the workspace, new file (any folder), save
Ctrl+O, Ctrl+I back and forward along the jumps, Vim's jump list (Normal mode): links followed, documents opened, and the page's own jumps (G, gg, %, { }, a mark's); back to another document opens it where you left it, in the view you left it in. Ctrl+O no longer opens a document: SPC o does
SPC f, SPC l, SPC j open a file anywhere, the links, the link under the cursor
SPC b the buffer card: 1 to 9 show the 1st to the 9th buffer in the tabs' order, 0 the 10th; d closes the one shown (File › Close buffer, :bd), asking first over unsaved changes; r and l close the buffers to its right and left, nearest first, each asked about as d asks, a Stay stopping there with that buffer shown; s switches buffer (Go › Buffers…, :b: every open file and draft, previewed with its unsaved text; :b 3, :b name); b goes back
H, L (Shift+h, Shift+l) in the page, in Normal mode, the buffer before or after the shown one, in the order of the GUI's tabs, wrapping at the ends (bufferline's keys, as in autovim). This replaces Vim's H and L (the screen's top and bottom line) in Normal mode only: Visual mode keeps them, Insert mode types them, and a script's own autodoc.map of H or L wins
SPC O, SPC d, SPC H the file's outline (Go › Outline…); the Mermaid diagram at the cursor (File › Preview Mermaid diagram…, or right-click View diagram); the HTML preview (File › Preview HTML)
File › Open with Default App the file in the desktop's default app: xdg-open, or open on a Mac
Ctrl+W switch workspace (SPC w too); its Manage… (or Go › Manage workspaces…) adds, edits and deletes them. In the Vim editor mode's Insert, Ctrl+W is Vim's: it deletes the word before the cursor (Esc first to switch), as Insert's Ctrl+U deletes back to the indent and Ctrl+O runs one Normal-mode command
Ctrl+h j k l in Normal mode, to the open panel on that side, and back to the page
SPC L arrange the panel with the keyboard: move and resize it (Go › Arrange panel…)
Shift+F10, the Menu key, SPC . the page's right-click menu, at the cursor (the Menu key where the terminal sends it)
Ctrl+=, Ctrl+-, Ctrl+0 in the GUI, zoom in, out, and back to 100 %
F1, F10, Ctrl+Q help, the menu bar, quit; Help › Tutorial… is the tutorial
CategoryKeybindingModeActionDescription
Editor ModeSPC k / Ctrl+Space kNormal / TextSwitch Editor ModeSwitch between the Vim (modal) and the Text (modeless) editor mode
Vim Modesi / a / I / A / o / ONormalEnter Insert ModeInsert before or after the cursor or the line; open a line below or above
Vim ModesEscInsert / VisualReturn to NormalLeave Insert or Visual mode
Vim Modesv / V / Ctrl+vNormalEnter Visual ModeSelect by character or by line or a block
Vim Modes: / Ctrl+;Normal / anyCommand LineOpen the command line (:w :q :find :replace :b :bd :go ...)
Navigationgg / GNormalBuffer ExtremesJump to the first or the last line
Navigation{ / }NormalParagraphMove by paragraph ([ and ] too)
NavigationCtrl+O / Ctrl+INormalJump ListBack and forward along the jumps; across documents too
NavigationSPC j / SPC b bNormalFollow Link / BackGo to the link under the cursor; go back to where you left
NavigationCtrl+h/j/k/lNormalMove Between PanesTo the open panel on that side and back to the page
Find/ / n / NNormalFind in PageFind in the page; the next or the previous match
Help?NormalVim Keys CardShow or hide the Vim keys' card
Find* / #NormalFind the WordFind the word under the cursor forward or back
BuffersH / LNormalPrevious / Next BufferThe buffer before or after the shown one in tab order
BuffersSPC b 1-9 / SPC b 0NormalShow the Nth BufferThe 1st to the 9th buffer in tab order; 0 the 10th
BuffersSPC b s / :bNormalSwitch BufferPick one of the open buffers
BuffersSPC b d / :bdNormalClose BufferClose the shown buffer (asks about unsaved changes)
BuffersSPC b r / SPC b lNormalClose to the Right / LeftClose the buffers to the right or the left of the shown one (each asked about; Stay stops)
Leader ChordsSPC / or SPC SPC / Ctrl+GNormalSearchSearch the workspace (full text / links / backlinks / frontmatter / embeddings)
Leader ChordsSPC oNormalOpen a DocumentA filter over the workspace's files with a preview
Leader ChordsSPC fNormalOpen a File AnywhereThe file dialog: any file on the machine
Leader ChordsSPC rNormalRecent FilesThe files opened lately
Leader ChordsSPC ONormalDocument OutlineList the file's headings; Enter jumps to one
Leader ChordsSPC lNormalRelationsFocus or toggle the links panel: the note's links and backlinks
Leader ChordsSPC xNormalTodo BoardFocus or toggle the .todo-list task panel
Leader ChordsSPC eNormalFiles ExplorerFocus or toggle the explorer: every workspace's folders and files
Leader ChordsSPC `NormalTerminalToggle the terminal: your shells in the workspace's folder
Leader ChordsSPC gNormalAI AgentToggle the AI agent panel
Leader ChordsSPC LNormalArrange a PanelMove it with h j k l and resize it with H J K L
Leader ChordsSPC M / F11NormalMaximizeMaximize or restore the terminal or the agents (the one with the keyboard; else the newest open)
Rendered ViewCtrl+TNormal / Insert / TextToggle Rendered ViewSwitch between the Markdown source and the native Rendered View in --gui (Mermaid / Vega-Lite / CSV)
Rendered ViewSPC HNormalPreview HTMLThe note's page: a pane beside the editor in --gui; in --ui an image dialog when the terminal can show one; else the browser
WindowCtrl+S / Ctrl+W / Ctrl+QNormal / TextSave / Workspace / QuitSave; switch workspace (in Vim Insert Ctrl+W deletes a word); quit

3.5 The Panels

The explorer, the links, the todos, the terminal and the AI agent each open over the page from an edge. Preferences sets the edge each first appears at, and Escape or the panel's key again closes it.

Tiled or floating: the layout

The page is a window of its own, and the explorer, the terminal, the agent, the results and the todos are each either floating (over the page, docked at an edge or anywhere you drag them, as above) or tiled (beside the page, sharing the screen with it). Each window's Layout says which.

flowchart LR
    subgraph Left["Left edge (the default)"]
        FILES["Explorer (SPC e)"]
        TODOS["Todos (SPC x)"]
    end

    subgraph Center["The page"]
        TABS["Buffers (H / L, SPC b)"]
        PAGE["The page: 120 columns, centred"]
    end

    subgraph Right["Right edge (the default)"]
        REL["Links: Relations (SPC l)"]
    end

    subgraph Bottom["Bottom edge (the default)"]
        TERM["Terminal (SPC `)"]
        AGENT["AI agent (SPC g)"]
    end

    subgraph Other["Placed by their own rules"]
        PREV["HTML Preview pane (SPC H, --gui)"]
        CARDS["Plugin cards (SPC p): where the plugin's manifest places them"]
        RESULTS["Results (Go › Results)"]
    end

    TABS --> PAGE
    FILES --> PAGE
    TODOS --> PAGE
    PAGE --> REL
    TERM --> PAGE
    AGENT --> PAGE
    PAGE --> PREV
    PAGE --> CARDS
    PAGE --> RESULTS

The panels

  1. The explorer (SPC e): every workspace's folders and files. Enter on a file opens it and closes the panel.

  2. The links (SPC l): what this file is connected to, by kind:

    • superseded by, supersedes, sources, cited by, amends, amended by, related and adr;
    • its links and its backlinks;
    • then what names nothing, and the supersession loops.

    d shows the files two links away, under the one that reaches them.

  3. The todos (SPC x): the workspace's .todo-list/ store, a tab for each status: Open, In progress, Deferred, Completed and Archived. s moves the selected task to another status, and A assigns it to an agent.

  4. The terminal (SPC `): your shells, in the workspace's folder. §3.8 says more.

  5. The AI agent (SPC g): an agent CLI in a terminal of its own, started in AutoDoc's folder for the workspace. With several agents running, Ctrl+Tab and Ctrl+Shift+Tab go to the next and the previous one's tab, as in the terminal.

  6. The notifications (SPC h, Go › Notifications…): a dialog listing what happened (a save, the connection, indexing). It is a dialog, not a panel: it has no edge and doesn't move.

  7. The results (Go › Results): a table of rows a plugin returns, such as a query's.

  8. Plugin cards (SPC p): a plugin's card, beside the page.

  9. The HTML preview (SPC H): under --gui, a pane beside the editor, the note's page drawn live as you type. In the terminal, a dialog shows the page as an image when View › Image previews is on, the terminal confirmed kitty graphics, and a headless Chromium or Chrome is there; otherwise the page opens in the browser.

The outline (SPC O) is a list over the page, not a panel.

Notifications

What happens — a save, a workspace added, the connection, indexing — shows in a corner as a toast, saying how long ago it came ("now", "15s ago"). Up to three show at once, the newest nearest the corner; the rest wait and show in turn. A finished one stays 3 seconds (1 to 10 in Preferences), a task's progress stays until the task ends, and Preferences moves them to any corner. Go › Notifications… (SPC h) lists every one, with its time. What the page says — a find's result, the editor mode — is the status line's, not a notification.


3.6 Preferences, and config.toml

The editor's and the panels' settings are preferences. Options › Editor preferences (SPC ,) sets them:

In --gui, Options › Renderer sets what draws the window, at the next start (the surfaces).

The daemon keeps them (preference.set), so --ui and --gui share them.

config.toml ($XDG_CONFIG_HOME/autodoc/config.toml, else ~/.config/autodoc/config.toml) configures the daemon itself. A setting it doesn't know is refused, not ignored:

[server]
socket = ""        # the unix socket; empty: the default
state_dir = ""     # the state directory; empty: the default
data_dir = ""      # the store's directory; empty: the default

[follow]
poll_interval = "2s"   # how often to list a root that can't be watched (the default)

[embedding_queue]
max_inflight = 1   # embedding requests at once, across every workspace: 1 (the default) or 2

The Options menu

Options is the menu for the editor:

About names the author, Yong Sung John Lee, and the license, Apache 2.0 (NOTICE).

The System menu

System, right of Options, is the menu for the backend:

Walkthrough: Reviewing an Architecture Decision

To see how the editor and the panels work together in practice, consider reviewing a proposed ADR (adrs/0048-hybrid-rrf-fusion.md) and its linked benchmark task:

  1. Open the Document (SPC o): Press SPC o, type 0048 rrf, and press Enter to open adrs/0048-hybrid-rrf-fusion.md in the center page.
  2. Survey Its Structure (SPC O): Press SPC O (Go › Outline…) to list the file's headings, choose ## 3. Reciprocal Rank Fusion Formula, and press Enter to jump there.
  3. Inspect What Links Here (SPC l): Press SPC l to open the Relations panel: the ADR's links and its backlinks, such as the synthesis notes and reviews that link to [[0048-hybrid-rrf-fusion]], and a task whose adr: names it.
  4. Follow a Link (SPC j): Move the cursor onto the [[wikilink]] naming the benchmark report and press SPC j to open it. SPC b b goes back to the ADR, where you left it.
  5. Check the Diagrams (Ctrl+T): In autodoc --gui, press Ctrl+T to switch the page into Rendered View, its diagrams, Vega-Lite charts, and CSV tables drawn in place. Ctrl+T again shows the source.
  6. Update the Linked Task (SPC x): Press SPC x to open the Todos panel, select the review task, and press s to choose its new status (the daemon's todos.status verb).

3.7 Files Changed on Disk

AutoDoc is file-canonical, so another program (git pull, an AI agent) may change a file you have open.

Open files follow the disk. The folder of every open file is watched (inotify, FSEvents; polled where neither is there), so a file another program or an agent changes is picked up at once: one with no unsaved changes is reloaded in place, one undo step, the cursor on its text; one with unsaved changes is marked "changed on disk" ([!] on its tab and in the Buffers picker) and asked about when you next open or save it, never while you type. A file deleted on disk keeps its text, marked "deleted on disk", and a save creates it again. Preferences' files changed on disk (tui.disk_reload) can ask first for clean files too. The TUI's own saves are never taken for a change.

A save writes only over the version the file was opened at. If the file changed on disk since, the TUI asks: keep editing, reload the disk's version (u brings your text back), or overwrite it with yours. Opening, switching or quitting over unsaved changes asks first, too. A lost connection loses nothing: the open file stays on the page through the reconnect, unsaved changes and cursor as they were. It is read again if it changed on disk meanwhile and has no unsaved changes; if it is gone, closing it asks first; if its workspace is no longer served, its unsaved text stays as the untitled draft.

Every way out, and recovery

Every way out asks over unsaved changes, and the answers are the same everywhere: Save (then quit once the file is written), Discard or Stay. That covers File › Exit, Ctrl+Q, SPC Q, :q, the too-small screen's Quit and the GUI window's close button. When AutoDoc ends without being asked to (SIGTERM, or SIGHUP because the terminal closed), the unsaved text is kept in the state folder's recovery/. At the next start AutoDoc says so: "<file> had unsaved changes when AutoDoc last closed … We kept a copy for you, just in case. Restore it?"


3.8 The Command Line (:)

: in the Vim mode's Normal mode opens VIM Commands (golib's editor prompt). Tab completes a command and lists the candidates with their arguments; Enter runs it; Esc closes it. Ctrl+; opens it in either editor mode.

Every command a user can run is in one command catalog, by a stable id (file.open, todos.open, terminal.toggle, lua.upper, plugin.<name>.<id>): AutoDoc's own, its features', your Lua commands and the plugins'. The command line, the keys, SPC p and Lua all run them from there, and F1 lists every one under COMMANDS, with its id, its : names, its keys and what it does. A plugin runs one with host.call (protocol 3, docs/plugins.md).

Command Does
:12 go to line 12 (refused past the last line)
:open <path>, :e, :edit open a file: its absolute path, ~/…, or a path in the workspace in use; spaces and all
:w, :wq, :x, :q, :q! save; save and quit; save if changed and quit; quit (asks over unsaved changes); quit discarding them
:find <term>, :nohl the page's find, as / is: marked, n and N go on; clear it
:terminal, :term open the terminal, with the keyboard in it
:todos the todos (SPC x)
:replace <term> <with> each match in turn: y replaces, n skips, q or Esc stops; one undo for all
:table <cols> <rows> a Markdown table (Column1…, Item1.1…). In Insert mode, Tab walks its cells and selects each one's text so typing replaces it; past the last cell, Tab adds a row
:mermaid <type> a Mermaid diagram to start from: flowchart, sequence, class, state, er, gantt, pie, mindmap, timeline, journey

The rest, and the long names of :w, :q and :x:

:write, :quit, :exit    The long names of :w, :q and :x
:b [<number or name>]   Show a buffer; alone, the buffer picker
:bd                     Close the buffer
:go [<name>]            Go to a widget (:go explorer, :go terminal/lua); alone, the Go-to picker
:lua [chunk]            A Lua shell, or run Lua
:lua-reload             Reload the Lua scripts
:lua-install <name or git URL>  Install a Lua package
:agent-buffer           Send the page to an agent
:agent-forward          Send the selection, or the clipboard, to an agent
:usage                  What AutoDoc uses

Every other command has a key or a menu row, and a Lua script reaches any of them with autodoc.run(id). A plugin's commands run from SPC p. autodoc --commands-reference lists every command AutoDoc is built with, by its id, with its : names (docs/commands.md). An agent AutoDoc started lists the live ones, your Lua and plugin commands included, with autodoc --editor editor.commands, and opens a file with autodoc --editor editor.open '["path"]'.

Finding and Replacing

In Normal mode, / finds in the page, n and N go to the next and previous match, and * and # find the word under the cursor, forward and back. (? is the Vim keys' card, not a search.) :find <term> finds from the command line, and :replace <term> <with> replaces each match, asking y or n at each.

The Terminal (SPC `)

The terminal runs your shells in the workspace's folder: at the bottom, or wherever Preferences puts it.

autodoc --call reaches the daemon from a shell:

# Search the workspace "kb" from the terminal
autodoc --call search.query '["kb", "rrf fusion", {"limit": 5}]'

3.9 Moving Your Keys (keymap.xml)

Every key is a command with an id, AutoDoc's (autodoc.window.save, autodoc.leader.openRecent) and golib's widgets' (tui.list.down, tui.editor.vim.normal.undo). A keymap.xml beside config.toml moves any of them, unbinds them, or gives one several keys; it is followed while AutoDoc runs, and a file it can't read is refused whole, with its line, the keys staying as they were. F1's help starts with the keys your file moves, and the cards name each by its new keys.

autodoc --keymap-reference   # the file's format, and every AutoDoc command with its keys
autodoc --commands-reference # every command, by its id, with its `:` names and arguments
autodoc --check-keymap       # check keymap.xml beside config.toml, with no UI or daemon

docs/keymap.md is the reference, with every id and its default keys; the walkthrough below walks through one.

Walkthrough: moving search to F5 and recent files to a capital R

  1. Write the file. Create ~/.config/autodoc/keymap.xml:

    <mapping>
      <shortcut id="autodoc.window.openSearch"><key value="F5"/></shortcut>
      <shortcut id="autodoc.leader.openRecent"><key value="Shift+R"/></shortcut>
    </mapping>
    
  2. Check it. autodoc --check-keymap reads the file as AutoDoc does and prints …/keymap.xml: valid (0 warnings). A misspelled id is refused with its line.

  3. Watch it apply. With AutoDoc open, the save applies on the next frame: F5 opens search, and Ctrl+G no longer does. Press SPC: the card lists Shift+R recent files.

  4. See what you moved. F1's help opens with YOUR KEYS, each moved command with its file and line.

  5. Break it on purpose. Change F5 to F55 and save: a notice names keymap.xml, line 2, and F5 still opens search. A refused file changes nothing.

Unbind a key with <key value=""/>. Give a command several keys with several <key> elements. A menu's underlined letter, a plugin's letters (their own preference) and your Lua keys can't be moved here; nor can the key after a prefix, such as the second g of gg.


3.10 The GUI Window

autodoc --gui               # the TUI in a window of its own, attached to the daemon as --ui is
autodoc --gui kb            # in workspace kb
autodoc --gui --debug       # also record the window's input stream and the TUI's trace (see Chapter 2, §2.2)

--gui runs the same screen as --ui in a native window (golib's gui, on Gio): the same keys, menus, dialogs and panels. Buttons, check boxes, text fields, tabs and scrollbars are drawn natively, in the theme's colours, and a dialog dims what is behind it. The window can be resized freely; below 80 × 20 cells it asks to be enlarged. Options › Fonts and zoom… chooses the fonts it draws in, and Ctrl+= and Ctrl+- zoom everything in it together.

On macOS, holding a letter repeats it instead of opening the accent picker, so holding j or k continues moving through the document. AutoDoc sets this preference for its GUI process at startup; no defaults command is needed, and other apps and saved preferences are unaffected.


← Previous: Chapter 02: Quickstart & Workspaces | Index | Next: Chapter 04: Rich Authoring, Embeds & Export →