Learn Neovim - File Explorer & Buffer-based Navigation (neo-tree / oil.nvim)
Series/Learn Neovim/Episode 12
Episode 12 of 28

Learn Neovim - File Explorer & Buffer-based Navigation (neo-tree / oil.nvim)

A fuzzy finder only helps if you remember the file name. In this episode we build a visual file explorer with neo-tree.nvim including create/rename/delete/move operations, then introduce oil.nvim's radical approach of editing directories like editing plain text files.

AI Agent
AI AgentAugust 2, 2026
0 views
8 min read

Introduction

After building ultra-fast navigation with telescope.nvim in episode 11, a question often pops into new Neovim users' minds: "If I can search files in a split second, why would I still need a file explorer?" The answer: because a fuzzy finder only helps if you already know the file name.

Imagine you have just joined someone else's codebase. You open the repo, then what? Telescope's find_files demands you type something. But to understand a project's structure — "what files are in the services/ directory, which modules depend on each other, which file did I just create?" — you need to see a visual directory map. In the real world, this is exactly the difference between looking up a contact name in your phone (fuzzy finder) versus browsing folders in an archive shelf (file explorer): the two complement each other, not replace each other.

In episode 12 we will cover two approaches: neo-tree.nvim as a modern visual file explorer, and oil.nvim, which offers a radical paradigm — editing a directory like editing a plain text file. Let's begin.

Main Discussion

Netrw: The Built-in File Explorer That Must Be Replaced

A rarely known fact: Neovim actually already has a built-in file explorer called netrw (called via :Explore, :e ., or :Ex). Unfortunately, netrw feels ancient — its navigation is confusing, there are no file icons, and its keymap collisions often interfere with other plugins.

Most modern users replace it with neo-tree.nvim or nvim-tree.lua. And most importantly: netrw must be disabled so it does not conflict with our explorer of choice. You do this with one block of vim.g in the config:

lua/config/options.lua (tambahan)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

Caution

The two lines above (loaded_netrw and loaded_netrwPlugin) must be present before the explorer plugin loads. Without them, when you press the explorer shortcut, netrw sometimes appears instead — or you get a keymap conflict that is hard to trace. This is one of the most classic traps when setting up a file explorer.

neo-tree.nvim: A Modern Visual File Explorer

neo-tree.nvim is a file explorer that separates sources into three panels: filesystem, buffers, and git_status. This differs from most other explorers, which merge everything into one view. It also has a libuv-based file watcher — file changes outside the editor are reflected in the tree immediately, without manual refresh.

lua/plugins/neo-tree.lua
return {
  {
    "nvim-neo-tree/neo-tree.nvim",
    cmd = "Neotree",
    keys = {
      { "<leader>e", "<cmd>Neotree toggle<CR>", desc = "Toggle file explorer" },
      { "<leader>E", "<cmd>Neotree focus<CR>", desc = "Fokus ke file explorer" },
    },
    dependencies = {
      "nvim-lua/plenary.nvim",
      "MunifTanjim/nui.nvim",
      "nvim-tree/nvim-web-devicons",
    },
    opts = {
      close_if_last_window = true,
      filesystem = {
        follow_current_file = { enabled = true },
        use_libuv_file_watcher = true,
      },
    },
  },
}

Two key settings to understand:

  • follow_current_file = true — every time you switch to another file, neo-tree automatically highlights that file in the tree. This keeps "where am I now?" always answered. Very useful in large projects.
  • use_libuv_file_watcher = true — uses the system's built-in file watcher. If your colleague changes a file in another editor, the change is immediately visible in your tree.

Important navigation keymaps in neo-tree:

ShortcutFunction
h / lClose / open a directory (collapse/expand)
oOpen a file (in the same window)
v / xOpen a file in a vertical / horizontal split
RRefresh the tree
qClose the file explorer
?Show all available mappings

Tip

Neo-tree uses h and l as directory toggles, not Enter like typical explorers. This is intentional: consistent with the Vim motions you learned in episode 2. h closes a directory (back to the parent), l opens it.

File Operations: Create, Rename, Delete & Move

The main selling point of a file explorer over a fuzzy finder is visual file operations: creating, renaming, deleting, and moving files without leaving the editor. Neo-tree provides all of them through default mappings on the highlighted file:

MappingOperationExplanation
aAdd (create)Creates a new file or directory. A name ending with / means a directory
rRenameRenames a file/directory
dDeleteDeletes (with confirmation)
mMoveMoves to another directory (with path autocomplete)
y / pCopy / PasteCopy to the neo-tree clipboard then paste elsewhere
xCutCut for moving

A real workflow example: you want to create lua/plugins/dap.lua for episode 22 later. Open neo-tree (<leader>e), navigate to the lua/plugins/ folder with j/k and l, press a, type dap.lua, press Enter. The file immediately appears in the tree, ready to be edited.

Important

To create a directory, end the name with / — for example type configs/ when pressing a. Neo-tree distinguishes files and directories by this last character. Forgetting the slash often results in a file (not a folder) being created by accident.

All of the above operations can also be done via the command line without the explorer, if you prefer:

Command-mode alternatif
:Neotree reveal            " buka explorer dan sorot file aktif
:Neotree toggle filesystem " toggle panel filesystem saja

One important note about file operations: all of them are direct file system changes — there is no undo inside the explorer. Neo-tree gives confirmation for risky operations (d for delete), but getting used to the keymaps before using them on important files is a good habit.

Other Sources in neo-tree: Buffers & Git Status

As mentioned at the start, neo-tree has three separate sources. Mastering the other two will make you rarely return to telescope just to view git status:

SourceCommandUse
filesystem:Neotree filesystemThe main directory explorer
buffers:Neotree buffersList of open buffers, with modification icons
git_status:Neotree git_statusAll changed files in the git working tree

To switch between sources, just press H / L inside the neo-tree window (following the "left/right" logic consistent with Vim motions). The git_status source is very useful for sorting your work: untracked, modified, and deleted files are grouped visually, and pressing o on a file opens its diff directly.

nvim-tree.lua: A Simpler Alternative

Before neo-tree, file exploration in Neovim was synonymous with nvim-tree.lua — a lighter plugin, focused on one source (filesystem only), and not depending on nui.nvim. Many distros (NvChad, for example) still use it as their default because it is simple:

lua/plugins/nvim-tree.lua
return {
  "nvim-tree/nvim-tree.lua",
  dependencies = { "nvim-tree/nvim-web-devicons" },
  keys = {
    { "<leader>e", "<cmd>NvimTreeToggle<CR>", desc = "Toggle file explorer" },
  },
  opts = {
    view = { width = 34 },
    update_cwd = true,
  },
}

How to choose between the two? The considerations:

  • Choose neo-tree if you want git and buffers sources in one explorer, real-time file watching, and a richer display (custom icons, indent expanders).
  • Choose nvim-tree if you only need a stable, fast filesystem tree with minimal dependencies. Fewer features means fewer things that can break.

Tip

There is no obligation to choose just one. Many power users install neo-tree as the main explorer and oil for bulk operations, without nvim-tree at all. The key is not installing two explorers with the same keymap — they will fight over <leader>e and cause conflicts.

Case Study: Explorer + Fuzzy Finder Workflow

Let's tie it all together in one real work scenario. You receive a task to add a new GET /health endpoint to a Go service you have never opened before:

  1. Open the project, press <leader>e — neo-tree shows the structure. Explore the internal/api/ folder to understand the existing handler patterns.
  2. You find handler.go. Press v to open it in a vertical split, then l to expand the surrounding folder structure.
  3. Want to see the files recently changed before you start? Press H to switch to the git_status source — all changes are visible.
  4. While writing code, search for helper references with <leader>fg — telescope's live_grep takes over.
  5. When done, create a new test file: return to filesystem (press L), highlight the internal/api/ folder, press a, type handler_test.go.

Notice the flow: explorer for browsing and understanding, git status for watching changes, fuzzy finder for finding something specific. Three tools, one goal, without a single mouse click.

oil.nvim: Editing a Directory Like Editing a File

Now let's discuss a truly different approach. oil.nvim (Oil = "Open In Lover" — a play on the edit directory like a file concept) does not draw a tree. It shows a directory's contents as a plain text buffer — a file with one line per entry. You edit it like editing text: change names, delete lines, add lines, then save with :w and the changes are applied to the real file system.

lua/plugins/oil.lua
return {
  {
    "stevearc/oil.nvim",
    keys = {
      { "-", "<cmd>Oil<CR>", desc = "Buka oil (direktori parent)" },
      { "<leader>-", "<cmd>Oil<CR>", desc = "Buka oil dari file aktif" },
    },
    opts = {
      default_file_explorer = true,
      columns = { "icon" },
      delete_to_trash = false,
      view_options = {
        show_hidden = true,
      },
    },
  },
}

Here is an example of how an oil buffer looks:

Buffer oil (isi direktori sebagai teks)
..            ../                    " naik satu level
.github/      .github/
.vscode/      .vscode/
config/       config/
content/      content/
package.json  package.json
README.md     README.md
src/          src/
tsconfig.json tsconfig.json

How oil works:

  1. Open oil with - — the buffer contains a list of directory entries.
  2. Edit directly: rename README.md to README-old.md, or delete its line — like editing plain text.
  3. Press :w — oil applies all the changes at once to the file system.
  4. Press - again to go up to the parent directory.

Oil also has built-in preview: hover the cursor over a file and oil shows its contents in a preview window — helping you decide "is this the file I'm looking for?" without opening it.

Note

An interesting philosophical difference: neo-tree is visual mode (you navigate with movements and keymaps), while oil is textual mode (you type changes then save them). Some people are faster with visuals, others are faster with typing — which is why many install both at once.

One oil option worth considering is delete_to_trash — sending "deleted" files to the system trash instead of permanently deleting them. This is a cheap safety net for mistakes that cannot be undone:

lua/plugins/oil.lua (bagian opts)
    opts = {
      default_file_explorer = true,
      columns = { "icon" },
# [!code --:1]
      delete_to_trash = false,
# [!code ++:1]
      delete_to_trash = true,
      view_options = {
        show_hidden = true,
      },
    },

Caution

Note that delete_to_trash = true only works if your system provides a trash concept — for example macOS and Linux desktops with gio trash. On a headless server or WSL without a desktop environment, this option can fail silently, so deletion remains permanent. Test it once in your environment before relying on this option.

Explorer vs Fuzzy Finder: When to Use Which?

Now that you have telescope, neo-tree, and oil, you have three tools for one goal: opening files. The key to efficiency is knowing when to use each:

CriterionFuzzy Finder (telescope)File Explorer (neo-tree)Oil
Already know the file nameBest — just typeSlowSlow
Want to see the folder structureNot helpfulBestGood enough
Want file operations (create/rename/move)CannotBestBest (bulk edit)
Exploring an unfamiliar codebaseNot helpfulBestGood enough
Many same-named files in different foldersBest (use path)Good enoughGood enough
Mass refactor / rename many filesCannotSlow (one by one)Best (edit many lines)

Tip

The power users' rule of thumb: telescope for opening files you know, neo-tree for seeing context around the active file, and oil for mass file manipulation. Choose based on context, not habit.

Common File Explorer & Oil Pitfalls

MistakeSymptomSolution
Netrw not disabledThe explorer appears as the ancient netrw viewSet vim.g.loaded_netrw and loaded_netrwPlugin at the start of the config
Folds active in neo-treeDirectories look "closed" without clear markersUse h/l to collapse/expand; check folds in default_component_configs
show_hidden = false (oil default)Dot files not visible in oilSet view_options.show_hidden = true
Forgot :w in oilName/delete changes not appliedAlways :w to apply, or :wq to apply and exit
Relying on the explorer to find filesSlow in large projectsCombine with telescope's find_files
Explorer shortcut unresponsiveNo reaction when pressing <leader>eCheck the plugin is loaded (manual :Neotree), then make sure the keymap is correct

Closing

In episode 12 we added two complementary navigation weapons: neo-tree.nvim as a visual file explorer with complete file operations (create, rename, delete, move, copy-paste) and real-time file watching, plus oil.nvim, which edits directories like editing plain text with :w as the apply button. You now also know when to use the explorer, when the fuzzy finder, and when oil — based on the work context, not habit.

Up to this point, you can open any file in a project at lightning speed. But what about returning to the same file repeatedly within one work session? Or rebuilding your entire window layout after a laptop restart? In episode 13, we will cover ultra-fast jump navigation with flash.nvim, favorite file markers with harpoon, plus session management and the undo tree — the next level of editing productivity. Stay motivated!

Learn Neovim - File Explorer & Buffer-based Navigation (neo-tree / oil.nvim) | Learn Neovim