vimtricks.wiki Concise Vim tricks, one at a time.

How do I use Vim's built-in file explorer netrw to browse and manage files?

Answer

:Explore

Explanation

Netrw is Vim's built-in file explorer plugin that comes with every Vim installation. The :Explore command opens a directory listing in the current window where you can browse, open, create, rename, and delete files without leaving Vim.

How it works

  • :Explore (or :Ex) opens the file explorer in the current window
  • Navigate directories with <CR> to enter, - to go up
  • Press <CR> on a file to open it
  • The explorer shows file sizes, dates, and permissions

Example

Useful netrw commands within the explorer:

<CR>  - Open file or directory
-     - Go to parent directory
%     - Create a new file
d     - Create a new directory
D     - Delete file or directory
R     - Rename file
i     - Cycle through view styles (thin/long/wide/tree)

Tips

  • :Sexplore opens in a horizontal split, :Vexplore in a vertical split
  • let g:netrw_liststyle = 3 sets tree view as default
  • let g:netrw_banner = 0 hides the help banner
  • :Lexplore opens a persistent sidebar explorer
  • Netrw can also browse remote files: :Explore scp://host/path/

Next

How do I visually select a double-quoted string including the quotes themselves?