Using Linux Vim System Clipboard Feature in Windows 10 Terminal for Remote Machine
In today's world of remote work and managing multiple machines with different operating systems, it becomes crucial to efficiently manage and transfer data within these machines. While working with a Windows 10 terminal using SSH to connect to a remote machine running Ubuntu 24 OS, there may be a need to transfer data seamlessly from one environment to another. This article will guide you on how to utilize Linux Vim system clipboard feature in Windows 10 terminal for a remote machine.
Prerequisites:
To follow along the guide, make sure you have the following:
- A Windows 10 terminal installed
- SSH client installed, for instance, OpenSSH or Git Bash
- A remote machine running Ubuntu 24 OS
- Vim (VIM-Vi IMproved 9.1) installed on Ubuntu 24 OS
Enabling Vim System Clipboard Feature:
By default, Vim does not utilize the system clipboard feature on Linux machines. However, enabling the feature only requires adding a few options to the Vim configuration file, vimrc. Execute the following command in the Ubuntu terminal:
<p>sudo nano ~/.vimrc</p>
This will open the vimrc file in the Nano editor. Now, add the following lines at the end of the file:
<p>" Enable copy and paste between Vim and the X11 clipboard</p><p>set clipboard+=unnamedplus</p>
Save and exit the editor by pressing Ctrl+X followed by Y and then Enter. Close the terminal session and reconnect using SSH.
Copying and Pasting Between Windows 10 and Ubuntu 24 OS:
First, ensure that the Windows 10 terminal supports and enables the copy-paste feature via the right-click menu or keyboard shortcuts. Next, follow the steps below for copying and pasting data:
- Copy the data from Windows 10 terminal (Ctrl+C or right-click copy) or other applications.
- Switch to the Vim editor session in the Ubuntu 24 OS terminal.
- Use the standard Vim editor commands for copy (
"*y) and paste ("*p) commands. - The data stored in Windows 10 terminal will be copied to the Vim editor.
Conclusion:
Utilizing the Linux Vim system clipboard feature in Windows 10 terminal for remote machines can significantly improve productivity when transferring or managing data across environments. By enabling this functionality, the copy-paste process becomes seamless, and users can handle multiple tasks efficiently in a single session.
Summary:
-
Enable Linux Vim system clipboard feature using
vimrcfile configuration options. -
Copy data from Windows 10 terminal or applications and paste directly to the Vim editor session in Ubuntu 24 OS.