Escape characters during paste in vim
Posted
by Michael Anderson
on Stack Overflow
See other posts from Stack Overflow
or by Michael Anderson
Published on 2010-04-21T05:36:04Z
Indexed on
2010/04/23
2:43 UTC
Read the original article
Hit count: 352
vim
I copy stuff from output buffers into C++ code I'm working on in vim. Often this output gets stuck into strings. And it'd be nice to be able to escape all the control characters automatically rather than going back and hand editing the pasted fragment.
As an example I might copy something like this:
error in file "foo.dat"
And need to put it into something like this
std::string expected_error = "error in file \"foo.dat\""
I'm thinking it might be possible to apply a replace function to the body of the last paste using the start and end marks of the last paste, but I'm not sure how to make it fly.
© Stack Overflow or respective owner