Set vim's working mode (temporary) :set (mode information) Today we will discuss a Vim usage skill - reading and writing remote files with Vim. To achieve this goal, we need to use a plug-in called What is the netrw plugin? Let's see how to use Vim to read and write files stored on a remote Linux system from your local system. Read and write remote files using Vim on Linux The method of reading and writing remote files is almost the same as editing remote files. To read a remote file from the local system, we can simply use the following command to open it: $ vim scp://[email protected]/info.txt Type To write a remote file from the local system, first open the file using the above command, then press The running process behind the command is actually to use the scp command to copy the remote file to the To check whether the remote file content has been modified locally, use this command: $ ssh [email protected] cat info.txt Please note that if you want to use the absolute path to the remote terminal directory, you should use double slashes as in the following command: $ vim scp://[email protected]//home/cirdan/Documents/info.txt If you have changed the SSH port for security reasons, you should explicitly state the SSH port number, as shown below: $ vim scp://[email protected]:2200/info.txt Here, port 2200 is our custom port number. You can use your own ssh port number instead of 2200 in the above command according to the specific situation. If you don't have an ssh/scp channel, you can use other protocols instead, as follows: $ vim ftp://user@remotesystem/path/to/file Reading and writing remote files in a Vim session If you are already in a Vim session, you can use the Nread (NetRead) and Nwrite (NetWrite) commands to read and write remote files. Suppose we now use the following command to open the Vim editor on the local system: $ vim Then you are in the Vim session. To read a remote file in the newly cached Vim session locally, just run the following command: :e scp://[email protected]/info.txt In addition, you can also use the :Nread scp://[email protected]/info.txt Or, enter: :Nread "scp://[email protected]/info.txt" To know more about this command, enter the following command in a Vim session: :Nread ? After reading the description file, enter Similarly, to write to a remote file, you should first use the following command: :e scp://[email protected]/info.txt Press the You can also create and write files with :w scp://[email protected]/info.txt After writing, press the In addition, you can also use the :Nwrite scp://[email protected]/info.txt For detailed information about the :Nwrite ? Summarize This is the end of this article about using Vim to read and write remote files in Linux system. For more relevant content about using vim to read and write remote files in Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of MySQL slow queries
>>: Using js to implement a number guessing game
1. Introduction Recently, I often encounter devel...
1. The color of the scroll bar under xhtml In the ...
Preface: As far as I know, currently CSS can only...
Result:Implementation code: <!DOCTYPE html>...
The json data must be returned in html format That...
vmware vsphere 6.5 is the classic version of vsph...
1. Download: http://www.oracle.com/technetwork/ja...
This week has been as busy as a war. I feel like ...
Table of contents 1. Global level 2. Database lev...
Configuration file that needs to be loaded when t...
Copy code The code is as follows: html { overflow...
In the past, creating a printer-friendly version ...
Table of contents 1. After downloading, unzip it ...
I encountered a strange network problem today. I ...
The common way to deploy a springboot project to ...