I've added the ability to my SmartCopyPlugin to automatically escape anything that gets pasted into a Java string literal, along with all the other goodies. It's very handing for pasting large text blocks into Java from non-Java sources. A future version will probably make similar functionality work with XML, HTML and JSP, if I can manage it.
While I've found this plugin very useful in my own development, I've had literally zero feedback on it from anyone. If anyone is using it, let me know. First one to say anything gets priority on features.]]>
Here's the goto:
and the feature list
This plugin adds a variety of useful editor actions, enhancing the cut, copy, and paste functionality of IDEA. As of version 0.2, this plugin uses the unsupported Psi interface to get access to IDEA's parse tree, so it could become unstable with any future release, yadda, yadda.
Paste As String: Pastes the current clipboard into the editor, wrapping it's contents in double quotes. Any characters not allowed in Java strings are escaped. Newlines are escaped, and also result in breaking the pasted string across lines. Thus pasting the following as a string:
Additionally, if you have an already existing string that you wish to paste into, this plugin overrides the paste command to do the escaping and breaking. I've found this action is useful for copying in queries from command-line SQL tools into java code. Default key mapping = control-shift-P
Copy-Append: Copies the current selection (or the current line if nothing is selected), appending it to the contents of the current clipboard. Default key mapping = control-shift-C
Cut-Append: Same as Copy-Append, but also deletes the selection. Default key mapping = control-shift-X
Smart Copy: The first time Smart Copy is used, it acts like a standard Copy operation. Subsequent times, it acts as Copy-Append. Paste (including Paste Above) resets the action. This makes it easy to bundle up sequences of copies for one paste. Default key mapping = alt-U
Smart Cut: Same as Smart Copy, but also deletes the selection. Default key mapping = alt-Y
Paste Above: Just like Paste (including auto-reformatting and auto-import), but pastes the contents of the clipboard into the line above the current caret position, rather than over the current selection. Default key mapping = alt-P