[SGVLUG] vim paste (was Re: Soliciting speakers)

Akkana Peck akkana at shallowsky.com
Sun Jan 13 12:45:00 PST 2013


Lan Dang writes:
> I can share a vim tip right now that will prove quite useful to certain people.  (I have heard complaints relating to this two or three times.)  If you want to paste text into vim and you don't want any auto-formatting to be done to it--like autoindent--you need to use paste mode, which you access through command mode using
> 
> :set paste
> Go into insert mode and paste your text.
> 
> When you're done,  go back to command mode and type:
> :set nopaste

Paste mode is fantastic. You can make it even easier to turn on like
this:

set pastetoggle=<F11>

That works whether you're in insert mode or not. So if you're typing
along and suddenly want to paste something with long lines, just hit
F11 and paste, no need to get out of insert mode. Way easier than
<ESC>:set tw=0i like I used to do before someone showed me paste mode.

My favorite vi command is . (just a dot). It repeats the last command.
So, for instance, if you want to delete the first two words on a
bunch of lines, and you don't feel like trying to figure out the
correct :,..+10s/.* .* // (or whatever) substitute command for it,
you can just do 2dw (delete the next two words on this line), then
return . return . return . etc.  It doesn't sound all that impressive
at first, I know, but try it, and you'll soon find it's your
most-used vi command.

	...Akkana



More information about the SGVLUG mailing list