IntelliJ: String paste auto quote escaping

IntelliJ has this strange feature (bug for me) wherein if I paste text with quote marks in it inside an existing String, then my quote marks get auto-escaped.

Thus, I can end up with strange code like this:

System.out.println(" lottery distribution: \" median = \" + median + \", madm = \" + madm + \", k = \" + k + \", delta = \" + delta  );

when what I want is this:

System.out.println(" lottery distribution: median = " + median + ", madm = " + madm + ", k = " + k + ", delta = " + delta  );

I am using IntelliJ 8.1.3.  I have searched under the Editor settings, and cannot find where to suppress this behavior.  I would be very grateful if you could tell me how to suppress it.

This bug was noted 6 years ago (altho the bug vote link in the second posting there no longer works).


p.s. this forum's web interface seems to have changed.  How are you supposed to format code examples?  I see icons for links, images, etc, but the usual forum code icon seems to be missing.  I had to hand format the font of the code snippets above, which is unacceptable in a forum devoted to programming...

2 comments

Hello Charlie,

There is a separate action for pasting without auto-escaping: Paste Simple.
You can remap the keyboard shortcuts to trigger Paste Simple by Ctrl-V.

IntelliJ has this strange feature (bug for me) wherein if I paste text
with quote marks in it inside an existing String, then my quote marks
get auto-escaped.

Thus, I can end up with strange code like this:

System.out.println(" lottery distribution: \" median = \" + median +
\", madm = \" + madm + \", k = \" + k + \", delta = \" + delta  );

when what I want is this:

System.out.println(" lottery distribution: median = " + median + ",
madm = " + madm + ", k = " + k + ", delta = " + delta  );

I am using IntelliJ 8.1.3.  I have searched under the Editor settings,
and cannot find where to suppress this behavior.  I would be very
grateful if you could tell me how to suppress it.

/message/3353182#3353182 (altho the bug vote link in the second
posting there no longer works).

p.s. this forum's web interface seems to have changed.  How are you
supposed to format code examples?  I see icons for links, images, etc,
but the usual forum code icon seems to be missing.  I had to hand
format the font of the code snippets above, which is unacceptable in a
forum devoted to programming...

---
Original message URL:
http://www.jetbrains.net/devnet/message/5260219#5260219

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


1

Dmitry: thanks for your prompt reply.

I am embarassed to admit that I was not aware of the Paste Simple option.

I think that I am going to skip the keyboard remapping, because I do want the "complicated" Paste for things like autoimport etc when I do non-String pastes.  But when I want to paste a String inside a String, I will try and remember to do a Paste Simple instead.  That should do the trick.

0

Please sign in to leave a comment.