Northern Commander

Opening files

Opening, viewing and editing a file ask the same thing whatever the file is; its kind decides how. Read this to know what a key will do to a file, and to change it for one file or for every file of a kind.

The context menu names what each of the five keys would do to this file.
KeyAction
EnterOpen
⌘OOpen or switch to
⌘↓Look inside
F3View
⇧F3View as text or hex
F4Edit
⇧F4Edit as text
⌘EnterWhat can I do with this

The five keys

Enter opens a file: goes into a folder, asks about an application, or hands a file to the app it belongs to. F3 and F4 keep it here, to look at and to change. The shifted keys are the alternatives: as they ship, the text-and-bytes viewer and the text editor, for every kind of file but applications and folders, where they do nothing. A kind of file can point them anywhere.

  • They act on the row under the cursor, never on marked rows, so one key never opens fifty files.
  • When you are not sure what a key will do, ⌘Enter starts with what each of the five would do to the file under the cursor — Open in TextEdit, View here — before you press one.

What each kind of file does

The kinds that ship, in the order they are checked. What each viewer shows is under File types.

Kind Enter F3 F4
Application bundles Asks: look inside or launch — —
Directories Go inside Measure it, showing its size on the row —
Disk images Go inside, as into a folder View here —
Other disk images Its app View here —
Installers and Java archives The menu View here —
Archives Go inside, as into a folder View here —
Images View here View here macOS’s editor
Film and sound View here View here macOS’s editor
Documents Its app View here if it is a PDF; the rest as bytes macOS’s editor
Libraries and object files The menu The executables viewer —
Kept searches Run the search The search form The search form
Text, source and configuration Its app View here Edit here
Programs for other systems The menu As text or bytes —
Scripts The menu As text or bytes Edit here
Archives, by what is in them Go inside View here —
Mach-O binaries The menu The executables viewer —
Programs The menu As text or bytes —
Anything that reads as text Its app View here Edit here
Anything a volume says may be run The menu As text or bytes Edit here
Anything else Its app View here macOS’s editor
View here
The viewer made for that kind of file, or the text-and-bytes viewer where there is none.
Edit here
The editor made for its format — JSON, YAML, XML, tables — or the text editor.
Its app · macOS’s editor
The app macOS opens it with, and the one macOS edits it with, which can be a different app.
The menu
The context menu, to choose from. Nothing is run on a single keystroke unless you set the kind to Run.
Asks
A small menu that opens on Look inside, with Launch beneath it. ⌘O launches an application at once, and ⌘↓ goes into it; both work whatever Enter is set to.
—
The key does nothing.

To make Enter launch applications, open File types…, choose Application bundles, and set its Enter to Open with system default. A change there is yours and stays as you set it.

A picture, a film or a sound that it can show opens here rather than in another app, because while you are browsing the viewer is instant. An archive is gone into like a folder; a kind that is not supported yet, such as an .arj, says so, and Open with… hands one to Archive Utility.

What each kind recognizes
Application bundles
.app, and what macOS calls an application.
Directories
Every folder.
Disk images
dmg.
Other disk images
sparseimage xip.
Installers and Java archives
pkg jar.
Archives
zip 7z rar tar gz tgz bz2 xz zst zstd tzst cab iso lha lzh, the parts of a split archive, and what macOS calls an archive.
Images
jpg jpeg jpe jfif png gif bmp tif tiff ico webp heic heif heics avif jxl tga svg svgz psd, and the camera RAW names listed under Pictures.
Film and sound
mp4 mov m4v avi mpg mpeg 3gp mts m2ts mp3 m4a m4b m4p aac wav wave aif aiff aifc flac caf au.

Both are the names a viewer here shows and no others. Any other picture, film or sound — MKV, WebM, Ogg, MIDI — is Anything else: Enter hands it to its app.

Documents
pdf epub doc docx xls xlsx ppt pptx pages numbers key rtf rtfd odt.
Libraries and object files
dylib bundle o so.
Kept searches
ncsearch — a search you kept.
Text, source and configuration
txt md markdown log csv tsv json jsonl ndjson xml html htm css yaml yml toml ini conf cfg plist c h cpp cs js ts py rb go rs java kt swift m sql diff patch gitignore; Makefile, Dockerfile, and names like .zshrc; and what macOS calls plain text or source code.
Programs for other systems
exe dll, and what macOS says can be run: Windows programs and libraries, Java classes.
Scripts
sh zsh bash command, and a file that starts with #!.
Archives, by what is in them
A file whose first bytes are a zip, gzip, 7z, RAR, bzip2 or xz archive’s.
Mach-O binaries
A file whose first bytes are a Mac program’s or library’s.
Programs
A file whose first bytes are a program’s — a Mac, Linux or Windows one.
Anything that reads as text
A file whose first bytes are text.
Anything a volume says may be run
A file with permission to be run.
Anything else
Every file.

:::

How a file’s kind is decided

The kinds are checked from the top of the list — your own first, then the ones that ship — and each key is decided on its own: the first kind that matches the file and says something for that key decides it.

  • A key left Not set on a kind passes on to the next kind that matches, so a kind of your own needs to say only what should be different. Do nothing is an answer: the key stops there and does nothing.
  • A kind matches a file when any one of its rules does. Rules on the name are asked first, then whether it is a folder or may be run, then what macOS knows of the name, and only then the file’s first 4 KB — read once, however many rules ask. So a kind that a name settles never reads the file, and a kind of your own that looks inside files, put at the top, reads every file you press a key on.
  • The kinds that ship are ordered the same way: everything recognized by its name comes before everything that has to be read. May be run is the last but one, because a disk from another computer can mark every file on it as runnable.
  • A kind that ships cannot be changed or moved. Editing one makes a copy of your own at the top, and the copy wins because it is checked first.

A kind of your own that matches *.log, with only Open set — to Console — sends every log to Console on Enter; F3 and F4 pass on to Text, source and configuration, as they did before.

Open with…

Open with… — in the context menu, just after opening, and in the Files menu — lists everything that can open the file under the cursor.

macOS's apps for the file come first; this application's viewers and editors are marked (here).
  • First the apps macOS offers for it. The one macOS would use is marked (default), and is chosen to begin with.
  • Then this application’s own, each marked (here): every viewer, the text and hex viewer, every editor, and the text editor. A viewer chosen here is given the file even if it would not otherwise take it.
  • Typing finds a row. Open opens the file with the one chosen.

Always open .md files with it keeps the choice for every file with that extension, as a kind of your own called .md at the top of the list:

  • It sets Open and nothing else: F3 and F4 go on as before.
  • Choosing again for the same extension changes that kind rather than adding another.
  • A file with no extension has nothing to keep it for, and the box is grayed.

A kind whose key is set to Ask which app opens this same list, every time.

Choosing a language

The text viewer and the editor color a file as the language its name, or its start, says. Language…, in their View menu, colors it as another language, or none.

  • Always color .md files like this keeps it, the same way as Open with…: a kind of your own called .md that names the language and sets no key. It is grayed for a file with no extension.
  • A file is colored as the language named by the first kind of your own that matches it and names one; failing that, the one its name says; failing that, the one the start of the file says.

More about opening files

  • Changing a file type — the File types screen, and every field of a kind of file: its rules, what each key does, an app, a command, its language.
  • File types in settings.json — your kinds of file as the settings file writes them, to write by hand or to share.