top image
home  /  pages  /  tech tips  /  contact about

Speeding up Vim's Netrw plugin over ssh/scp

Problem

You edit files over ssh/scp by using Vim's Netrw plugin, but writing the file is still slow.

A related article discusses filename completion with Vim's Netrw plugin.

Keywords

Vim, Netrw, ssh, sshfs, scp, ControlMaster, ControlPath.

Solution

Use ssh's ControlMaster and ControlPath (see the ssh_config man page) to share multiple ssh connections over a single network connection. That cuts out the cryptographic handshake on each file write, sometimes speeding it up by an order of magnitude.

Add to your ~/.ssh/config

# you change "*" to the hostname you care about
Host *
  ControlMaster auto
  ControlPath /tmp/%r@%h:%p

Then create an ssh connection to the host and leave it running.

ssh -N host.domain.com

Now open a file remotely with Vim's Netrw and enjoy the zippiness.

vim scp://host.domain.com//home/user/.bashrc

URL: https://thomer.com/howtos/netrw_ssh.html
Copyright © 1994-2022 by Thomer M. Gil
Updated: 2011/04/04