Paste hell - how to stop Idea from inserting \n in strings?

Hi folks,

I'm trying to figure out how to stop Idea from inserting \n in strings which span multiple lines. Breaking up the string with "" + "" is fine, but inserting "\n" + "" is just wrong as now its breaking up stuff that is supposed to be on the same line.

1
37 comments
Avatar
Permanently deleted user

No it doesn't. Make a long string in notepad and paste it into Intellij. It still shows up as a single line. The program that you are copying from is inserting the new lines.

0
Avatar
Permanently deleted user

This thread only shows that the topic needs to be discussed more. Blindly implementing things because a handful of users are louder than others is a very bad idea. It led to several mistakes in Intellij (such as removing organize imports from the format code options).

The people at JBrains have learned this, and are trying to understand the problem before they implement a solution. It doesn't help that lots of people think they want it. It helps to have enough use cases to suport the feature.

0
Avatar
Permanently deleted user

I agree. I've run into this case a few times. If one escaped string is copied (from idea) to another string in idea, it makes a mess. The auto-escaping feature is still very helpful and is what I'm looking for 90% of the time. I wouldn't mind the undo feature, but would prefer 'dumb-paste' or 'paste-special' to be a seperate action (it seems silly to do something with the intention of undoing part of it with the very next keystroke).


I think one issue here is one of 'source'. If the
CUT is from completely
within a string (things are already escaped), the
paste needs to know that
so that it doesn't re-escape things that are already
escaped. This could
possibly be done within IDEA, but there's nothing
IDEA can do about it if
you cut from another application.

I think the only solution is to either allow an
'undo' step, as has been
indicated, or have a separate "dumb-paste" that
doesn't try to escape the
string contents, so that you can invoke "dumb paste"
if you KNOW the
contents of the clipboard are already properly
escaped.

Personally, I think the undo-thing is probably more
intuitive and easy to
do.

0

>That is essentially what M$ Word does when it automatically changes something.
>For instance, with some commonly mistyped words it will autocorrect for you.
>Sometimes the word is mispelled on purpose (i.e. documenting common mistakes in
>another document). Entering the undo command (Ctrl-Z) will undo the autocorrect
>the first time, and a second time will undo the typing.

They also allow you to turn that behavior off.

0
Avatar
Permanently deleted user

Ah - emulation of C#'s @"literal string" feature. That would definately get some of my votes...

It would need to be more than just a display thing though, you would have to be able to edit it as a literal as well.

0

This is a shameless plug, but you can alway install my IDEAmacs plugin and use its "yank" command which always will paste without manipulating the pasted text in any way.

0
Avatar
Permanently deleted user

I swear I had a request for an inline "string editor," but I can't find it. Basically IDEA would show all literal strings as boxes of text, and you would edit it like normal text, with newlines, and backslashes, and anything you wanted, but underneath, it would be adding the escaped version to the actual Java file.

0

Please sign in to leave a comment.