Neovim for Beginners — File Explorer

Configure file explorer for Neovim, with and without plugins.

alpha2phi

--

Neovim for Beginners — File Explorer

Exploring files and directories is what we do daily. Let’s check out how Neovim can help us. We are going to

  • Explore Netrw (:h netrw) which is the built-in file browser supporting local and remote file browsing.
  • Configure sensible defaults for Netrw and check out vinegar.vim that enhances Netrw.
  • Install and configure nvim-tree, a Lua-based plugin for Neovim.

This article is part of the Neovim for Beginners series.

The Neovim configuration files can be found in this repository.

Netrw

All Vimmers should have some basic knowledge of Netrw.

Netrw makes reading files, writing files, browsing over a network, and
local browsing easy. It supports many protocols like scp, ftp, http, rsync, sftp, fetch, dav, etc (:h netrw-ref).

We can use it to read a remote file.

nvim scp://hostname/path/to/file
nvim ftp://hostname/path/to/file

We can use it to browse a remote directory.

nvim scp://hostname/
nvim ftp://hostname/path/to/dir/

Local browsing is easy.

nvim .
nvim /home/userid/path

Commands

From within Neovim, we can use the :edit or :e commands to browse the directory. E.g. :e $HOME to browse the home directory, or :e . to browse the current directory.

Other available commands are

  • :[N]Explore[!] [dir]- Explore the directory of the current file.
  • :[N]Hexplore[!] [dir] — Horizontal Split & Explore.
  • :[N]Lexplore[!] [dir] — Left Explorer Toggle.
  • :[N]Sexplore[!] [dir] — Split & Explore the current file’s directory.
  • :[N]Vexplore[!] [dir] — Vertical Split & Explore.
  • :Texplore [dir]— Tab & Explore.
  • :Rexplore — Return to/from the Explorer.

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.