Vim staircase effect

Posted by Arkham on February 28th, 2008

If you are terminal vim users, I’m sure you have tried to copy/paste text into a file and thought “Wtf, this is pretty damn wrong” seeing something like this:

randomize (void)
       struct timeval *tv = malloc (sizeof (struct timeval));
            struct timezone *tz =
                  (struct timezone *) malloc (sizeof (struct timezone));
                 gettimeofday (tv, tz);
                      srand (tv->tv_usec);
                           free (tv);
                                free (tz);

That’s called vi staircase effect.

The solution is to type:

:set paste

before pasting and

:set nopaste

after finishing.

Alternatively, just add to your ~/.vimrc:

nnoremap <silent> <F12> :set paste!<CR>

to press F12 for toggling between paste and nopaste conditions.

This entry was posted on Thursday, February 28th, 2008 at 03:05 and is filed under computers. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Tags: , ,

Comments are closed.