IntelliJ IDEA使用技巧,复制字符串连接文本到剪切板
比如有以下代码,字符串中是一个查询男生、女生人数的 sql
public class Test {
    public static void main(String[] args) {
        // 查询男生、女生人数
        String sql = "select sex,count(*)" +
                "from student" +
                "group by sex;";
    }
}

如果我想复制出 sql,一般的做法是先复制出以下内容:
"select sex,count(*)" +
                "from student" +
                "group by sex;"
然后再删除双引号和加号,得到需要的内容
select sex,count(*) from student group by sex;
这样做比较麻烦,使用 idea 有更简便的方法
技巧
将光标置于字符串的值处,然后按Alt + Enter(Mac 是 option + return) ,选择 Copy String Concatenation Text to the Clipboard

复制结果如下,它会删除所有的 " 和+ ,注意它不会将其放在1行上,还是会有3行,但已经很方便了。
select sex,count(*)
from student
group by sex;
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号