DEV Community

andrescuco
andrescuco

Posted on • Edited on

4 3

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

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay