IntelliJ has some automatic String escaping built in.
IntelliJ automatic String escaping on copy/paste
Example: pasting TO IntelliJ
Write some code:
String s = "";
Then paste this sequence between the double quotes: <li><a href="#">
What you have is:
String s = "<li><a href=\"#\">";
IntelliJ intelligently escaped the double quotes for you.
Example: copying FROM IntelliJ
Select the string literal above, including the surrounding double quotes ("<li><a href=\"#\">"), and paste it into Notepad. What you get is exactly that.
Select the string content, excluding the double quotes (<li><a href=\"#\">"), and paste it into Notepad. What you get is the string unescaped: <li><a href="#">
That's pretty smart, and most always what I want.
IntelliJ automatic String escaping on search
Example: ctrl-alt-f searching for <li><a href="#"> does not find our code String s = "<li><a href=\"#\">";
Here's an idea for the IDEA team: how about a checkbox "Find escaped strings"?
Of course, in practice it'll get a bit more complicated than just handling the double quotes. Depending on the programming language. JavaScript has single quotes, there are regular expression and SQL escapes, etc. And I'd want to be careful with the search-and-replace functionality (or just not offer this feature there).
No comments:
Post a Comment