Viewing files
The viewer shows one file over the whole window, as text or in a view made for its kind — a table as a table, a picture as a picture, a recording playing with its waveform. Use it to look at a file without opening another application.
- Header
- The file’s name and size. The text viewer adds how the file is read and which line you are on — see the header line.
- Line under the file
- In a view of its own, what the file says about itself: a picture’s size, a table’s rows and columns, a document’s word count.
- Key bar
- What each function key does here, now.
At a glance
| Key | Action |
|---|---|
| F3 | View |
| ⇧F3 | View as text or hex |
| ⇧F4 | Edit this file |
| Esc | Close |
| ⌥→ | Next file |
| F4 | As text |
| ⇧F9 | All it says about itself |
| F7 | Search… |
| F9 | Menu bar |
Opening a file
| Press | And the file is shown |
|---|---|
| F3 | For what it is: in a view of its own if the viewer knows its kind, and as text if not |
| ⇧F3 | As text — or as its bytes, if it is not text — whatever kind of file it is |
- Both act on the row under the cursor, never on marked rows. On an application they do nothing. On a folder the key of F3 is F3, which measures it and shows its size on the row.
- To look at one file after another without opening each, turn the other pane into the preview pane.
- F3 chooses the view by the file’s name. A file that turns out not to be what its name says — a
.pngthat is really text — is shown as text instead. - A file its view cannot show — damaged, or not readable — opens as text or says why in the file’s place. It is never left on Reading….
- A pipe, a socket or a device has no contents to show, whatever its name: the viewer and the preview pane say so instead of opening it.
- Enter shows pictures, films and recordings here too.
- Nothing you press in the viewer changes the file.
- From any terminal,
ncmd view notes.txtopens a file here — see Command line. - What these keys do for a kind of file can be changed — see Opening files.
A view for each kind of file
A file of a kind the viewer knows opens in a view made for it. Six of them:
Headings are ruled off, lists and tables drawn, code blocks colored by their language. F2 shows the document typeset as a page instead, with its pictures.
CSV and TSV files, and JSON Lines files. A JSON or YAML file that is a list of records opens as a tree; Show as a table shows it as a table instead, and back. The column names stay along the top and numbers line up on the right. F2 sorts by the cursor’s column; ⌘C copies the selected cells.
JSON, YAML, XML and property lists. → opens a branch and ← closes it; typing a name jumps to it. F5 copies the value under the cursor, and ⇧F5 the path to it.
Fitted to the window. F3 shows it pixel for pixel, + and - zoom, and the arrows move it about.
A recording starts playing as it opens; Space or F2 pauses it. The waveform scrolls past the playhead, with the whole recording underneath — click either to go there. F6 skips to where the sound starts again after a pause, and F5 turns the spectrum into a spectrogram. MP3, AAC, WAV, AIFF, FLAC and CAF.
A film starts playing as it opens. Space pauses, ← and → go back and on five seconds, Page Up and Page Down thirty. A click on the bar under the picture goes to that point, and a click on the picture pauses or plays. MP4, MOV, M4V, AVI, MPEG and more.
A view’s own keys are on its key bar and in a menu named for it.
The keys each view adds
Each kind of file has a page of its own in File types, with everything its view does. The keys, in short:
| Key | Action |
|---|---|
| F2 | Fit to the window |
| F3 | Actual size |
| F5 | Rotate |
| ⇧F5 | Rotate back |
| Key | Action |
|---|---|
| F5 | Next page |
| ⇧F5 | Previous page |
| Key | Action |
|---|---|
| F2 | Play or pause |
| F5 | Spectrum |
| F6 | Next pause |
| ⇧F6 | Previous pause |
Trees: JSON, YAML, XML, property lists
| Key | Action |
|---|---|
| F2 | Open or close everything |
| F5 | Copy value |
| ⇧F5 | Copy where it is |
Tables: CSV, TSV and JSON Lines
| Key | Action |
|---|---|
| F2 | Sort by this column |
| ⇧F2 | Sort by it the other way |
| ⌘C | Copy |
| ⌥⌘C | Copy with options… |
| ⇧F5 | Copy row |
| ⌘L | Select row |
| ⇧⌘L | Select column |
| ⇧Enter | Open cell as text |
| F6 | Show only the matching rows… |
| ⇧F6 | Show all rows |
| Statistics of this column | Statistics of this column |
| F8 | Freeze the columns left of the cursor |
| ⌥⌘→ | Make the column wider |
| ⌥⌘← | Make the column narrower |
| ⌘← | Go to the first column |
| ⌘→ | Go to the last column |
| ⌘↑ | Go to the first row |
| ⌘↓ | Go to the last row |
| ⌘G | Go to… |
| Show as a table | Show as a table |
| ⌥F4 | How it is read… |
| Key | Action |
|---|---|
| ⌘↓ | Next change |
| ⌘↑ | Previous change |
| ⌥→ | Next file of the difference |
| ⌥← | Previous file of the difference |
| F5 | Copy this file's difference |
| ⇧F5 | Copy this hunk |
| F8 | Side by side |
| F6 | Ignore white space |
| ⇧F6 | Swap the two sides |
| ⌘→ | Take into the right file |
| ⌘← | Take into the left file |
Markdown, web pages, notebooks, programs
| Key | Action |
|---|---|
| F2 | Typeset |
| F5 | Allow what it fetches… |
| F2 | Next cell |
| ⇧F2 | Previous cell |
| F2 | Next architecture |
| ⇧F2 | Previous architecture |
Seeing it as text instead
F4 shows the same file in the text viewer — to read the source of a document, or when a view gets a file wrong. It does not come back: close the viewer and press F3 again for the view.
What can be changed about a view
F10 lists everything that can be changed about the view in front, with how each stands now: a picture’s size and which way up it is; a comparison side by side or stacked, with or without white space, and which file is on the left; how a table is cut into cells and what its rows are in order by; a Markdown file typeset or as text; every branch of a tree open. Each has its own key as well, named at the end of its row while you are on it. Nothing changes until OK or Apply. A star after an option’s name says it is not remembered: it lasts no longer than the file is open.
Everything the file says about itself
⇧F9 puts a panel in place of the file, with everything it records about itself — a photograph’s camera and lens, a document’s outline, a recording’s tags. The arrows and page keys scroll it; the same key, or Esc, puts it away. A value too long for the window goes on to the next row rather than being cut off.
In a patch, the panel lists the files the patch changes: choose one with the arrows and press Enter to go to it.
Going on to the next file
⌥→ shows the next file in the pane and ⌥← the one before, without going back to the pane — in a view of its own and in the text viewer alike.
- It goes in the pane’s own order, and stops at the first file and the last. The pane’s cursor goes with it, so closing the viewer leaves it on the last file shown.
- Each file is shown the way F3 would show it, a program with no extension included. A file with no view of its own is shown as text.
- A folder is passed over, and so is a file you have set F3 to open in another application.
- Where the view has no search — pictures, documents, Markdown — Space goes on too, and ⇧Space or ⌫ goes back. Over a film or a recording, Space plays and pauses instead.
- In a diff, the same keys move between the files the diff changes.
- In the text viewer only ⌥→ and ⌥← step; Space does nothing there. Wrapping and line numbers stay as you set them from one text file to the next.
Menus and the key bar
F9, or a tap of ⌥ on its own, opens the menu bar over the viewer. The text viewer has File, Edit, View, Search and Options; a view of its own adds a menu named for it — Table, Tree, Playback — and has Search only if it can be searched.
The key bar says what each function key does here:
- A blank cell does nothing here; a gray one cannot now — F3 before anything has been searched for.
- A key that turns something on and off says which way it will go: Wrap, then Unwrap.
- Hold ⇧, ⌥ or ⌘ and it shows what each key does with that held.
F1 opens the help for whichever viewer is up.
The mouse
In the text viewer the wheel scrolls the file — in a filter it moves the page and leaves the chosen line where it is. Dragging selects text to copy — see selecting and copying.
In a view of its own, what the mouse does is the view’s:
| In | Do | And |
|---|---|---|
| A picture | Drag | Moves it |
| Scroll | Zooms in and out around the pointer | |
| Double-click | Switches between fitting the window and actual size | |
| A table | Click a cell | Goes to it |
| Drag | Selects the cells from where you pressed to where you let go | |
| Drag the line between two column names | Sets the column’s width | |
| Click a column’s name | Sorts by it; again, the other way; a third time, back to the file’s order | |
| The panel of details | Scroll | Scrolls it |
| A patch’s panel | Click a file | Chooses it; a second click, or a double-click, goes to it |
A click on the key bar does what that key does, in every viewer, with whatever modifier is held. The header and the line under the file take no clicks.
Closing
Esc goes back to the panes, with the cursor on the last file shown: the one opened, or the one ⌥→ and ⌥← stepped to. If the panel of details is up, the first press puts that away.
Open the file again and it goes back to where you left it — see where you left it.
Where you left it
A file opens at the line, the tree node, the table cell or the PDF page you last saw, one place per file, shared with the editor. A table also keeps the column widths you set. Pictures, recordings and the other views start at their beginning.
- A line a command’s output names wins over where you left the file.
- A file changed since opens at the same place, or its last line or page if it got shorter. A node or a cell that has gone opens at the top.
- A file left at the top keeps nothing. At most 500 files are remembered.
- Turn it off with Reopen files where they were left. Files inside archives are not remembered.
More about the viewer
- Text and bytes — the text viewer: moving about, the header, wrapping, line numbers, invisible characters, the bytes, selecting and copying, encodings, colors, big files and files that change.
- Searching a file — finding text or bytes, showing only the lines that match, and going to a line.