IntelliJ IDEA使用技巧,复制字符串连接文本到剪切板

比如有以下代码,字符串中是一个查询男生、女生人数的 sql

1
2
3
4
5
6
7
8
9
10
public class Test {

public static void main(String[] args) {
// 查询男生、女生人数
String sql = "select sex,count(*)" +
"from student" +
"group by sex;";
}

}

image.png

如果我想复制出 sql,一般的做法是先复制出以下内容:

1
2
3
"select sex,count(*)" +
"from student" +
"group by sex;"

然后再删除双引号和加号,得到需要的内容

1
select sex,count(*) from student group by sex;

这样做比较麻烦,使用 idea 有更简便的方法

技巧

将光标置于字符串的值处,然后按Alt + Enter(Mac 是 option + return) ,选择 Copy String Concatenation Text to the Clipboard

image.png

复制结果如下,它会删除所有的 "+ ,注意它不会将其放在1行上,还是会有3行,但已经很方便了。

1
2
3
select sex,count(*)
from student
group by sex;

参考

Copying a concatenated constant to the clipboard

串接(Concatenation)- wikipedia

打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!

扫一扫,分享到微信

微信分享二维码
  • Copyrights © 2015-2023 高行行
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信