Many times we need to work with remote servers. And often we edit files from those remote servers. One of the obvious solution to edit those files is to log in to the remote sever and edit files. But sometimes it is convenient to edit those files from local machine because we might have installed and configured various plug-in on our local system. In this chapter, we will discuss following items −
Vim supports remote file editing using following syntax −
In above example vim will recognize that it has to use scp protocol and it will access file using that protocol. For instance −
$ vim scp://email@example.com//tmp/message.txt
Above command will open /tmp/message.txt file from remote-server. It will use SCP protocol and jarvis user’s credentials for authentication.
Vim supports nread and nwrite functionality which stands for net read and net write respectively. Previous section shows method to access remote file while launching Vim. But what if you are already in Vim? Then you can use following commands −
In addition to reading we can also modify file on remote server directly. In that case use Nwrite command as follows −
Once file is opened, you can use regular Vim commands.
In addition to SCP, Vim supports following protocols −