If you’re working in Vim and paste something into the terminal, sometimes you’ll get a “staircase” effect where each line is progressively spaced farther outward, like so:
line 1 line 2 line 3 line 4
Obviously, this isn’t usually desirable.
To correct this, you can enable paste to prevent the staircase effect. In command mode, type:
:set paste
This isn’t on by default. When paste is enabled, it disables mapping and some other functions, so you probably want to know how to turn it off as well:
:set nopaste
Happy vimming!
Cool, thanks for the tip!
Thanks a lot for the tip!
I was nagged by this more occasions than once.
Thanks! As a fairly new user of Vim I’ve been looking for a solution to this. I don’t know why but if Vim is started directly I don’t get the stair-effect, but when called from Mutt I get it. “:set paste” works perfectly. Vim is so complex it sometimes takes a lot of time to even find straight forward info about basics.
I’ve always used
:set noai
to set ‘no auto-indent’. Seems to have the same effect though.
Can vim auto-justify text without cutting words? The only tool I know of that does that well is pico (now called ‘nano’) editor. To do that in nano you size the window just a bit bigger than you want the text to be and press Ctrl+J
If I could do that in vim that would be great, what I do now is save the file in vim, exit vim and use nano to do the justify.
I have the following key binding:
set pastetoggle=
in my ~/.vimrc so I can just poke F9, paste something and poke F9 again to go back to normal.
I usually get that problem with ai, but I never imagine that paste/nopaste would have the same effect. I need ai while writing code and I rather leave it on if set paste does the trick.
Did you consider turning off autoindent which is what causes the staircase effect?
:set noai
the difference with noai (no autoindent) is that paste goes a bit further:
it paste the buffer “as is” regardless of any end of line return
i.e.: let’s say you have a tw=72 (typing a text with formatting lines of 72 characters), then the nopaste has better effect on copied text than noai.
Like lefty.crupps, I have always done a :set noauto or :set no auto indent, depending on OS and weather vi or vim was used. But will try the set paste
I was not aware of the paste parameter. I would use “set noautoindent” instead. I’ll have to try the paste command the next time I need to eliminate stairstepping.
Thanks
Hurray, now my next question:
how to set vim so that the arrow keys allow for navigation within the text and not inserting lines with a capital D in it?
keess2 at schoen dot mine dot nu
I usually do
:r!cat
then paste and end with ^D
Thanks for the cool tip…
Thanks for a nice tip. I often face this problem.
I use the ‘set paste’ option as well as some other neat tricks (status line in vim).
Take a look at some of the handy options I employ here:
http://ddhj.homeip.net/wiki/doku.php/profile_tricks_examples#vim