oil-global-mode

oil-global-mode: the `-` key — from any buffer, open the directory it lives in.

On this page

One key, everywhere: - shows you the directory the thing in front of you lives in, as an oil listing.

It is a minor mode that is on in every buffer. You do not turn it on; it is how - reaches buffers that are not directory listings themselves.

What - does

You are in-
A fileOpens oil on the file's directory, with the cursor on that file.
An oil listingSteps to the parent directory, with the cursor on the directory you left.
A file tree rowOpens oil on the row's directory — the directory itself for a directory row, the parent for a file row.
Anything elseOpens oil as a bare :Oil would: on the current file's directory when there is one, otherwise the working directory.

Because the cursor lands on where you came from, - then <CR> round-trips: press - in a file, look around, press <CR> on the same row and you are back in the file.

:Oil with no argument does the same as - from a file. :Oil /some/dir opens that directory with the cursor on the first row.

Seeing it

:describe-key - describes the binding, and <C-h> m lists oil-global-mode in the buffer's mode stack. :describe-mode oil-global-mode describes the mode itself.

  • oil-mode — the listing - opens, and how to edit a directory through it.
  • file-tree-mode — the read-only tree view.