Vim Is Much More Powerful Than You Think: Netrw

By Alireza Alavi4 minutes read


Table of Contents

Table of Contents

  1. Cool shortcuts
  2. Remote Files

I've been using Neovim for almost 3 years now, and I only used it's built-in Netrw to navigate my project. I always thought Netrw is just a simple file explorer, allowing you to see directories and move between them. That's all. No tree, no copy pasting or moving files, no opening files in other applications.
Man, was I wrong.

Of course I knew about the R key which allows you to rename files/dirs, % which allows you to create new file,D that removes the file/dir and things like that. But no more to be honest. I would just do !thunar .& when things got a bit complicated.

It never amazes me that no matter how much I use and learn about Neovim or Vim, there's still a lot that I don't know.
Today I accidentally pressed i in Netrw and saw that it has a tree view of your directories. The thing I was most missing from Netrw and it was right there!

You can learn everything about it just by pressing <F1> and going through the manual, but here's a quick list.

Cool shortcuts

Remote Files

This is honestly so awesome.
You can just communicate with your remote files from SCP, FTP, SSH, Rsync, curl, dav etc.

I will mostly use this for working on my servers.
If you use SSH keys to authenticate to your server, it will be as simple as

nvim rsync://[user]@[host]/[filepath]

For example:

nvim scp://[user]@[host]//opt/docker-compose-files/

If you want to navigate a dir, add a / at the end of the filepath.

If your SSH key has a password, in your terminal do:

ssh-agent $SHELL
ssh-add // this will ask you pass once
nvim rsync://[host]/[filepath]

If you don't have SSH on your destination but have FTP/SFTP do:

nvim sftp://[user]@[host]/path/to/file

NOTE: To be honest I haven't been able to actually work with files in remote sessions with nvim. I haven't gotten much time to troubleshoot it, but I will update with my experiences. If you know how to work with remote file systems, contact me