Northern Commander

Editing files

The editor changes a file’s text over the whole window, with the same keys the panes use for the same kind of thing. Use it for the configuration file, the script or the few lines of code that are quicker to change here than to open somewhere else.

The cursor is on count, so its other uses are marked. The marks beside the numbers show where blocks fold.
Header
The file’s name, with • after it while there are changes not yet saved, and the whole line turns orange. On the right: how the file will be written, the language, and the cursor’s line and column of how many lines — see the header line.
Line numbers
With a rule beside them that marks where a block can be folded.
Key bar
What each function key does here, now.

At a glance

KeyAction
F4Edit
⇧F4Edit as text
⇧F7New file
F2Save
⇧F2Save as…
⌘ZUndo
⇧⌘ZRedo
F7Find and replace…
EscClose

Opening a file

Press And
F4 The file opens in whatever edits its kind — see below
⇧F4 The file opens here as text, whatever kind it is
⇧F7 An empty file opens here, with no name until you save it

What F4 does by kind of file:

Kind Opens in
Text, source code, configuration, scripts, anything else that reads as text This editor
JSON, YAML and XML; CSV and TSV This editor, in the format’s own view — a tree, or a table
Pictures, films, sound, PDFs and office documents, anything not listed here The application macOS edits that kind of file with
Folders, applications, archives, programs and libraries Nothing
A kept search The find form, on that search
  • Both keys act on the row under the cursor, never on marked rows.
  • ⇧F4 opens a JSON file or a table as plain text, too. On a folder or an application it does nothing.
  • What F4 does for a kind of file can be changed — see Opening files.
  • From any terminal, ncmd edit notes.txt opens a file here, and ncmd edit --wait makes this the editor git and other programs write their messages in — see Command line.
  • The whole file is read before you can type; opening… is in the header meanwhile. A file over 64 MB is refused, and says so — ⇧F3 reads a file of any size.

A new file

A file opens where you left it, with the same first line and the cursor where it was, in this or the viewer; Reopen files where they were left turns that off.

⇧F7 opens an empty file called (new file). Nothing is written until you save it: the first save asks for a name, in the folder the pane was in when you pressed the key, and the save key’s label says Save as until then. Close it without saving and nothing is left behind.

Moving around

  • The arrows, Page Up and Page Down move as they do everywhere. Going up and down keeps to the column you started in, across shorter lines.
  • Home goes to where the line’s text starts, and a second press to the very start. End goes to the end of the line.
  • ⌘← and ⌘→ move by words. ⌘↑ or ⌘Home go to the start of the file, and ⌘↓ or ⌘End to its end.
  • ⌘G goes to a line by its number — see going to a line.
  • Hold ⇧ with any of these to mark as you move.

Typing

What you type goes in at the cursor, or in place of what is marked.

  • ⌥⌫ takes the word before the cursor, and ⌘⌫ the line back to its start. With a block marked, either takes the block.

  • Enter starts the new line as far in as the line above, up to where the cursor was. On a line of nothing but spaces it leaves that line empty rather than keeping them.

  • A line you start ends the way the file’s lines already do, so a file from Windows stays CRLF.

  • Brackets and quotes close as you type them — see brackets.

The tab key

With Tab ⇧Tab
Nothing marked Puts in a tab, or spaces to the next tab stop Takes one level off the line
A mark within one line Replaces it, as any key does Takes one level off the line
A mark across lines Indents every line it reaches, one level Takes one level off each of them
  • A level is however the file already indents: a tab, or its number of spaces, which the editor header shows (“tab indent”, “2-space indent”). A file that mixes the two takes whichever most of its lines use. A new file, one with no indent yet, and a near tie use Indent with spaces and Spaces in an indent. Taking one off removes a tab, or up to a level’s worth of spaces — whatever is there.
  • Empty lines are never indented.
  • The lines stay marked, so the key can be pressed again. Each press is one step of undo.

Marking a block

Hold ⇧ and move, or drag with the mouse. ⌘A marks the whole file and ⌘L the cursor’s line, its line break included — so deleting it deletes the line.

  • A movement key without ⇧ ends the mark at its near end: ← at its start, → at its end.
  • Double-click marks a word, triple-click a line — see the mouse.

Column blocks

A column block is a rectangle down the lines rather than a run along them — for a file laid out in columns, or the same change on several lines at once. Hold ⌥ with the arrows, the page keys, Home or End, or ⌥-drag. The header says column while there is one.

Typing into a column block types on every line of it.
  • Typing, Backspace and Delete act on every line. Afterwards the block stays, with no width, just after what changed — so the next key goes on every line too.
  • A line too short to reach the block is left alone.
  • The block is measured in screen columns, so a tab in one line does not bend it.
  • A movement key without ⌥ ends it. One reaching across a fold opens the fold.
  • Brackets and quotes are typed as they are, never closed for you.

Duplicating and moving lines

KeyAction
⌘DDuplicate line or block
⌃⌘↑Move line or block up
⌃⌘↓Move line or block down

⌘D copies the cursor’s line below itself, or all the marked lines. Marked text within a single line is copied right after itself, on that line. The copy stays marked, so pressing the key again duplicates it again. ⌃⌘↑ and ⌃⌘↓ move the line, or the marked lines, up or down one line. With a column block, they act on the block’s lines and the block stays a block. Each press is one step of undo. In the panes ⌘D is Add to favorites. ⌥ with the arrow keys marks a column block.

Copying, moving and deleting a block

KeyAction
F5Copy block
F6Cut block
F8Delete block
⌘VPaste text

They sit on the numbers that copy, move and delete files in the panes.

  • Copy and cut put the text on the macOS clipboard, where any other application can paste it. F8 puts nothing there.
  • With nothing marked, copy and cut take the line the cursor is on. Pasted with nothing marked, a line taken that way goes in as a line above the cursor’s, wherever on it the cursor is.
  • A column block is copied a line at a time.
  • Pasted into a column block, one line goes on every line of it. Several lines go one to a line from the top, carrying on below the block as far as the file goes; lines left over are not pasted, and the header says how many.

Undo

KeyAction
⌘ZUndo
⇧⌘ZRedo
  • There is no limit to how far back.
  • Typing in one place is one step; so is a run of Backspace or Delete. Moving the cursor ends the step. A paste, a block deleted, a replace-all, an indent or a comment is one step however many lines it changed.
  • Undo puts back what was marked, as well as the text.
  • Saving does not end the history: undo past a save, and the file is changed again.
  • Anything new after an undo throws away what redo would have put back.
  • A change inside a fold opens it, so you see what came back.

Saving and closing

KeyAction
F2Save
⇧F2Save as…
EscClose

F2 writes the file where it came from. ⇧F2 asks for a name:

In …
The folder a bare name is saved in — at first, the file’s own folder.
Name
A name, or a path of its own. A name already there is asked about before it is replaced.

From then on the editor is that new file; the one it was opened from is left as it was. A file that has never been saved asks for a name on F2 too.

Esc goes back to the panes, with the cursor on the file. With changes not saved, it asks first:

Cancel is chosen at first, so Enter changes nothing.
  • Save writes the file and closes. Discard closes without writing it. Cancel goes back to it.
  • JSON, YAML, XML or a property list whose text does not parse is asked about before it is saved, from F2 and from Save here: A file that no longer parses.
  • Every save is in the journal: a new file as made, which could be undone, and an existing one as replaced, which could not — what it held before is not kept.
  • Nothing is saved for you, and nothing unsaved survives the application stopping.

How a save is written, and what happens when the file no longer parses, changed underneath or cannot be written, is in How a file is written.

JSON, YAML, XML and tables

F4 opens JSON, YAML and XML as a tree, and CSV and TSV as a table — each change made there is made to the file’s own text. In the editor, F4 switches between that view and the text, the same unsaved file either way, with the cursor on the same place. On the key bar it says View over the text and Text over the view.

  • A file that does not read as its format opens on the text, where it can be put right.
  • Over the view, save, save as, undo, redo and close work as they do over the text; the other keys are the view’s own, its search among them. Brackets, comments, laying out, folding, the encoding, How it is written and Editing settings… are for the text only — switch to it first.
  • ⇧F4 opens the text straight away.

What the tree and the table can do is in Structured data and Tables.

Settings

Editing settings…, in the View menu, sets how the editor lays text out and what it does as you type. It has no key.

The same settings as Options › Settings › Viewer and editor.

These are the settings on Viewer and editor, which says what each does. OK sets what you changed and closes, Apply sets it and stays, and Cancel leaves what you have not applied, asking first; a dot, •, stands beside a setting changed and not yet applied. What is set takes effect at once, reaches the next file you open, and is kept like any other setting. ⇧F9 turns Show spaces and line endings on and off without the dialog.

F10 lists what the editor shows, with how each stands now: line numbers, spaces and tabs, tab stops, other uses of a name, the language the text is colored as, and the format’s own view where the file has one. A star after an option’s name says it is not remembered: it is for the file you are in. The rest is kept.

The size of the text is the whole application’s — see Menus.

F9, or a tap of ⌥ on its own, opens the menu bar over the file: File, Edit, Search, View and Options, with a menu named for the format — Tree, Table — while its own view is showing.

The View menu, over a Go file. What has no key is still here.
  • The key bar shows what each function key does now: a blank cell does nothing here, and a gray one cannot now — Next before anything has been searched for.
  • Hold ⇧ and it shows the other half: Save as…, Back, Writing, Spaces.
  • ⌘K finds any command by name, Editing settings… and Language… included.
  • F1 opens the editor’s own help.

The mouse

Do And
Click Puts the cursor there. In the line numbers, at the start of that line
Double-click Marks the word, the run of spaces or the run of punctuation under the pointer
Triple-click Marks the line
Drag Marks from where you pressed, by characters — or by words or lines after a double- or triple-click. Past the top or bottom, the file scrolls to follow
⇧-click Carries the mark on to where you click
⌥-drag Marks a column block
Right-click Offers cut, copy and paste. On the marked block they are about it; anywhere else the cursor goes there, and they are about its line
Click the arrow by a number, or the … lines after a fold Folds or unfolds that block
Scroll Moves the file, not the cursor
Click the key bar Does what that key does, with whatever modifier is held

The header takes no clicks.

More about the editor

  • Finding and replacing — finding text, replacing it once or everywhere, and going to a line.
  • Writing code — colors and languages, brackets, comments, other uses of a name, laying a file out, and folding.
  • How a file is written — the header, encodings and line endings, what a save does, a file that no longer parses, and files that change underneath or cannot be written.