Vim copy paste adding newlines
Solution 1:
Gedit is using 4 spaces per indent, your VIM looks like it's using 8 spaces per indent.
There's nothing wrong, just a simple setting difference.
Look up the options:
- shiftwidth
- softtabstop
- tabstop
- expandtab
:set sw=4 sts=4 ts=8 et
will make your VIM look like your Gedit.
Solution 2:
I assume you're pasting from the clipboard or something? Try :set paste
before pasting.
The first thing I do on any new machine is put set paste
in my vimrc. I prefer paste mode as the default behaviour.
Edit:
And you can use :set nopaste
to turn paste mode off and the auto-format back on.
Solution 3:
you probably have vim's autoindent mode on. try turning it off with :set noautoindent
also, as mentioned by CR above, :set paste
greatly improves vim's behaviour while pasting text into it...with paste mode set you don't need to mess around manually setting text-width, wrap-margin or anything else likely to mess up long lines or text spacing. remember to use :set nopaste
when you've finished pasting.