You are not logged in.
Need expert's help:
When I copy from windows Firefox to my vnc's vim xterm, somehow after each line, several blank lines are added after every single line/paragraph. This is really annoying!
I don't know how to solve it. I changed a my .vimrc to a very simple one, still not working.
thanks!
Qian
Offline
In vim:
:set paste
Then use paste. Does that work?
Edit: I'm not a vim expert.
Last edited by drcouzelis (2012-05-23 03:31:51)
Offline
DOS line endings are "\r\n" whereas Unix line endings are "\n". Pasting into the terminal is probably doubling the number of newlines that were in the original text. If you run dos2unix on text before you paste, it should work. But for an automatic solution, I think you are going to have to get creative with how you configure vim.
6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.
Offline
I tried ":set paste" before I paste the texts, not working.
I also tried dos2unix command: I saved the pasted texts to a .txt file, then run dos2unix to this file to convert, nothing was really converted, those extras are still there.
Offline
You may have a fileformat problem. I'm pretty sure this will work but I only did one small test.
To display the current vim fileformat – this should return either 'dos' or 'unix'.
:set ff
Vim usually correctly sets the fileformat automatically upon opening a file but will default to using 'unix' if the format can't be determined. After pasting the text, try the command,
:update
'update' will save the file only if changes to the buffer have occurred. This command may change the fileformat and all the line endings are now CR-LFs (CR=carriage return; LF=line feed). Check the fileformat again with
:set ff
If ':update' didn't change the line endings, or the file is now a mix of CR-LFs and LF-only line endings, try this,
:e! ++ff=dos
This should force rereading the buffer as a dos (Windows) format and properly display the lines. All line endings should now be CR-LF. You can then manually set the fileformat to 'unix' with
:set ff=unix
and finally, save the file with
:w
Offline
Thanks "thisoldman", I tried the steps you mentioned, it still didn't work. You are right that my vim "set ff" shows unix format. I also tried to open a new vim window, manually ":set ff=dos", then paste some text from web, it still does not work. BTW, I was running vim on a Linux server 2.6.18-238.9.1.e15 .
To give you an example, I just went to the site: http://www.archlinux.org/ . On the front page , it shows below text, when I copy to my vim xterm, it shows 3 blank lines after each paragraph. But in fact it should be just one blank line after each paragraph.
--------
A simple, lightweight distribution
You've reached the website for Arch Linux, a lightweight and flexible Linux® distribution that tries to Keep It Simple.
Currently we have official packages optimized for the i686 and x86-64 architectures. We complement our official package sets with a community-operated package repository that grows in size and quality each and every day.
------
Offline