Why are there extra spaces after a new line when pasting using the screen?

I am using the screen to copy the code that I am viewing using Vim from one window to another window, currently editing a file with Vim. Unfortunately, when pasted into the second window, I get more and more white space to the left of my input after each new line. How does this space find its way in my buffer?

I tried to disable auto-indentation if Vim added extra spaces, but the problem persists.

Here is information that may be relevant:

  • OSx 10.6.8
  • Both files are Unix style.
  • Screen Version: 4.00.03
  • Vim Version: 7.3
  • Base Terminal Type: xterm-color
+7
source share
2 answers

Do you copy using the mouse or any other methods other than vim? If so, you should do :set paste before :set nopaste and :set nopaste after. See :h pastetoggle for quick comparisons.

If all your vim sessions are local and Vim supports it ( :echo has('clipboard')<CR> should echo 1 ), you should use your system clipboard: "+y to let yank and "+p paste without it annoying indentation.

Or, better, open your files in the same Vim session.

+19
source

The problem arises from listchars and eol Vim adds a character at the end of the line, some user adds, for example, ↲

To remove this extra char, you do not need to install eop in listchars, for example:

 set listchars=tab:\ \ ,trail:-,extends:>,nbsp:\ ,precedes:< 
tab

will be replaced by spaces, spaces with - will appear, etc.

Since there is no eol, it will not be displayed, this will fix your problem.

0
source

All Articles