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.
- On your terminal, run
vim ~/.ssh/config
to either create or modify an existing config file - 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
- 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.
Top comments (0)