Vi/Vim - avoid tabs when you copy/paste

December 2016

The Linux operating system has ample text duplication ability within a text editor. Vi and Vim include some of the useful Linux commands, including copy and paste. Using the Y or YY copy command one or multiple lines can be copied. The operating system lets you copy as many lines as you need. To paste you can use "p". If you want it pasted above the cursor buffer use a capital "P". In case you want it to be pasted below the cursor buffer, use small case "p" respectively.
You can tug or yank text into a line, by using the yank text commands of Linux from the location of the current cursor up to the word or till the end of the line, respectively. To paste text in a line use the same commands. However when you copy and paste in Vi or Vim (through a remote SSH session), it adds incremented tabs on each line, to solve the issue set paste in the window or add the set paste in /etc/vim/vimrc or in the~/.vimrc file.


Issue


By default, when you copy and paste in Vi or Vim (through a remote SSH session), it adds incremented tabs on each line.

Solution


To solve this problem, simply type: set paste in the window or add the set paste in /etc/vim/vimrc or in the ~/.vimrc file

Related :

This document entitled « Vi/Vim - avoid tabs when you copy/paste » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.