Netrw Vim Nav Basics
Netrw is a built-in plugin in Vim that lets you explore filesystems and network protocols such as ssh, ftp, http, etc. It’s a highly useful tool for browsing your local files or remote servers right from your Vim editor. Here’s how you can use it:
-
To open Netrw:
You can open netrw by typing
:Explore
,:E
or:Ex
from within Vim. This will open a file explorer in the current directory. -
To navigate in Netrw:
- You can move up and down the file list using the arrow keys or
j
andk
. - Press
Enter
oro
to open a file or directory. - Press
-
to move up to the parent directory.
- You can move up and down the file list using the arrow keys or
-
Creating, renaming, and deleting files:
- To create a directory, press
d
and enter the directory name. - To create a file, press
%
and enter the file name. - To rename a file or directory, place the cursor over it, press
R
, and enter the new name. - To delete a file or directory, place the cursor over it and press
D
.
- To create a directory, press
-
To navigate between multiple directories:
You can split the screen into multiple windows, each viewing a different directory:
:Vex
or:Vexplore
to open a vertical split:Sex
or:Sexplore
to open a horizontal split:Te
or:Texplore
to open in a new tab
-
Accessing remote directories:
You can open remote directories by typing the following command:
:e scp://user@host//path/to/directory
for SSH:e ftp://user@host/path/to/directory
for FTP
You’ll need to replace
user
,host
, and/path/to/directory
with the username, host address, and path of the directory you want to open, respectively. -
Sorting files:
- Press
s
to sort files by name, date, size, or extension.
- Press
-
File marking:
- Press
mf
to mark a file. - Press
mu
to unmark a file. - Press
ma
to mark all files. - Press
mr
to remove all marks.
- Press
These are the basic features of netrw, but there are many more features you can discover by typing :help netrw
within Vim, which will open up the full netrw documentation.
Remember that some functionality of netrw, like navigating remote systems, will require that you have the necessary packages installed on your system, like ssh
for accessing remote systems via scp
.