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,:Eor:Exfrom 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
jandk. - Press
Enteroroto 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
dand 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:
:Vexor:Vexploreto open a vertical split:Sexor:Sexploreto open a horizontal split:Teor:Texploreto open in a new tab
-
Accessing remote directories:
You can open remote directories by typing the following command:
:e scp://user@host//path/to/directoryfor SSH:e ftp://user@host/path/to/directoryfor FTP
You’ll need to replace
user,host, and/path/to/directorywith the username, host address, and path of the directory you want to open, respectively. -
Sorting files:
- Press
sto sort files by name, date, size, or extension.
- Press
-
File marking:
- Press
mfto mark a file. - Press
muto unmark a file. - Press
mato mark all files. - Press
mrto 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.