How to paste a string without Idea escaping it?

For example, I paste this:
IN (" + statusList + ")"

into another string and it comes out as:
IN (\" + statusList + ")\"

How can I stop this?

12 comments
Comment actions Permalink

Just so it is on the thread:

You can paste without the formatting, autoimport, literal escaping, etc. using 'Paste Simple'.

Menu -> Edit -> Paste Simple
or
Ctrl+Alt+Shift+V

3
Comment actions Permalink

Very silly, I think a ctrl-shift-V would be fine to get normal pasting behaviour.

1
Comment actions Permalink

You can turn Escape text on paste in string literals off in Settings | Editor | General | Smart Keys | Javascript to avoid strings escaping on paste

1
Comment actions Permalink

I don't think you can. Silly isn't it?

Heres the tracker item for it:
http://www.intellij.net/tracker/idea/viewSCR?publicId=14177

N.

Travis Reeder wrote:

For example, I paste this:
IN (" + statusList + ")"

into another string and it comes out as:
IN (\" + statusList + ")\"

How can I stop this?

0
Comment actions Permalink

What about following suggestion: when IDEA detects, it would need to
escape the string (on paste), than it could show a dialog asking for
escape or not escape. Since this dialog would only occur when pasting
into a string, it would not occur for all "normal" cases.

What do ya' think?

Tom

0
Comment actions Permalink

or display an intention by the text (like MS Word XP)

"Escaped Text" or "Text"


0
Comment actions Permalink

I personally prefer Travis' idea to use a slightly varied key combination. Much less intrusive than a popup confirmation.

0
Comment actions Permalink

Although having re-read your suggestion Tom I think I now like that one better... now if only I could delete / edit my previous post. :)

I missed the part where you said it would only be activated if the paste was into a string, which to make makes a whole lot of sense... even if I don't!

0
Comment actions Permalink

This is quite old thread but I could not find better one.

Idea's automatic (un)escaping in copy-paste is REALLY annoying feature.
I find out that there is also simple paste that partially solves the problem.
I changed keyboard shortcut Ctrl+V to run simple paste.
It works correctly (the way I want it to work) inside Java editor but not in whole IDE in general.
For example if I copy escaped text from string literal and paste it to search field embedded to Java editor (the one that opens with Ctrl+F keyboard shortcut) then IDEA still unescapes copied text and the result is that search cannot find text I am searching for.

So is there any way to get rid of this annoyance in whole IDE?

0
Comment actions Permalink

Hello Jari,

So is there any way to get rid of this annoyance in whole IDE?


I'm afraid there is not, can you please file a bug report at http://youtrack.jetbrains.net/issues/IDEA#newissue=yes

Probably related issue: http://youtrack.jetbrains.net/issue/IDEA-65819

Regards,
Kirill

0
Comment actions Permalink

Yes this is an old thread and  seems the problem still persists at least in WebStorm. 

It is especially annoying now that JavaScript supports multi-line a.k.a template-strings which means I often paste some code into a template-string which then has a lot of \t  character-combinations in it which I have to manually remove each of them.  They don't appear if I type a TAB inside a template-string, only when I paste some content into a template-string.

I also don't understand why the pasted content has tabs in it, I have as best as I can un-checked all "Use Tab character" options from different file-types in Settings -> Code Style.  :-) 

 

 

0
Comment actions Permalink

@ Elena Pogorelova  Thanks for the advice. Solved the problem

0

Please sign in to leave a comment.