Tip: Edit Files on a Server Using Your Local Vim Config

andrescuco

andrescuco

Posted on May 7, 2022

Tip: Edit Files on a Server Using Your Local Vim Config

Recently I found out that you can edit files that are hosted on a server with vim using the scp protocol, and keep your local .vimrc / init.nvim config!

On this tutorial I'll be editing files that are hosted on an EC2 instance, to do this you'll need:

  • A .per or .cer file for authorization
  • The ip address that you'd normally use to connect to your server through ssh

And that's it! Let's first setup the permissions.

  1. On your terminal, run vim ~/.ssh/config to either create or modify an existing config file
  2. Copy and paste the following, replacing it with your own server values
 Host your-ec2-instance-name
 Hostname 2.89.32.932
 User ubuntu
 IdentityFile /Users/myname/path/to/your-ec2-instance-name.cer
 PasswordAuthentication no
Enter fullscreen mode Exit fullscreen mode
  1. Run vim scp://your-ec2-instance-name/home/ubuntu/my-file.txt

And that's it! You might be prompted with a message to authorize the host in which case you'll need to type yes.

editing a file on a server through scp

💖 💪 🙅 🚩
andrescuco
andrescuco

Posted on May 7, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related