DEV Community

Cover image for Edit remote files with Vim
jones268
jones268

Posted on

Edit remote files with Vim

Vim is a text editor with a huge following. It's installed by default on every Linux system and even on Mac OS X.

Vim is a tool that wants you to succeed. if you want something to happen, you can make it happen. It works completely by keyboard shortcuts.

vim editor

It gives you the power to manipulate text at a fundamental level. you can operate on individual characters, words or lines of text this gives vim a really powerful interactive feel.

If you are new to vim, I recommend these exercises

Remote files with vim

I am often connecting to remote machines and editing config files.

This was cumbersome, as I would have to use SFTP to copy files, manually updating the buffer when the file was modified on the remote machine.

It was too easy to get distracted and lose track of what I was doing.

If you want to edit files on a remote server, try this command:

vim scp://you@remote_ip//path/file.txt
Enter fullscreen mode Exit fullscreen mode

and change username to your username, your remote ip, the path and the filename.

vim scp://frank@192.168.2.7//home/frank/hello.txt
Enter fullscreen mode Exit fullscreen mode

If you have vim open, you can also do :e scp://you@remote_ip//path/file.txt

You can use sftp too:

vim sftp://user@remote_ip//path/file
Enter fullscreen mode Exit fullscreen mode

Change it with your username, remote ip and path to the file.

vim sftp://frank@192.168.2.7//home/frank/hello.txt
Enter fullscreen mode Exit fullscreen mode

If you want to use the old unencrypted ftp protocol

:e ftp://[user@]machine/path/
Enter fullscreen mode Exit fullscreen mode

Vim is relentlessly awesome. It does everything an editor should do and nothing it shouldn't. There are no gimmicks, no silly settings, no bloat. It just works. all the time. no exceptions.

Top comments (0)