Sometimes I copy/paste from one .cpp to another in vim, and vim, confident that it knows what I want to do better than me, edits my entry. For example, if I copy/paste this:

// A comment.

vim would replace it with this:

// A comment.
//    Some(code);

How do I disable that?


One option may be to remove the "r" formatoption, with:

:set formatoptions-=r

and also possibly other options, all of which I found at: https://vi.stackexchange.com/questions/1983/how-can-i-get-vim-to-stop-putting-comments-in-front-of-new-lines

  • (also an indirect pointer to the vim.SX site) – Jeff Schaller Apr 26 '16 at 18:36

Go into paste mode:

:set paste

after pasting, you want to end paste mode:

:set nopaste

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.