1

Following answer I got there to allow >> to indent, I edited my .vimrc to this:

:set shiftwidth=2
:set autoindent
:set smartindent

But now when I copy/paste (via putty), it indents incrementally, by inserting unwanted "tabs".

I copy

#include <iostream>
int main() {
    std::cout << " Hello Vi and Vim!";
    return 0;
}

and when I paste in edit mode, it indent incrementally and it becomes:

#include <iostream>
    int main() {
            std::cout << " Hello Vi and Vim!";
                    return 0;
                        }

It won't happen if I remove my .vimrc. Does it ring any bells?

4

Yup, you should set the paste option to prevent indentation.

set paste

When you are done, you should then set nopaste.

What happens is that the pasted file is already indented but Vim try to indent it as well, the paste option prevent this.

You can also set a key to turn paste on and off with, e.g.:

set pastetoggle=<C-P>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.