[英]How to stop IntelliJ IDEA splitting strings in Javascript?
I am trying to write some SQL code as a string within Node.js (Javascript) and each time I press the enter
key IntelliJ is splitting the string like such:我正在尝试将一些 SQL 代码作为 Node.js (Javascript) 中的字符串编写,每次我按下
enter
键时,IntelliJ 都会像这样拆分字符串:
This:这个:
db.query('SELECT insertRecord($id, $name, $location, $title)');
Becomes this:变成这样:
db.query('SELECT insertRecord(' +
'$id,' +
'$name,' +
'$location,' +
'$title)');
Which is insanely annoying to the point of being unworkable.这非常烦人,以至于无法使用。 I just want it to do this:
我只是想让它这样做:
db.query('SELECT insertRecord(
$id,
$name,
$location,
$title)'
);
This is not SQL string splitting which can be turned on/off in File > Settings > Editor > Smart Keys > SQL .这不是SQL 字符串拆分,它可以在File > Settings > Editor > Smart Keys > SQL打开/关闭。 This seems to be Javascript string splitting for which I can't find an on/off option.
这似乎是 Javascript 字符串拆分,我找不到开/关选项。 Is there a way to stop this behaviour?
有没有办法阻止这种行为?
JavaScript doesn't allow line breaks in string literals (in double/single quotes), the IDE adds concatenation to keep your code valid. JavaScript 不允许在字符串文字中换行(在双引号/单引号中),IDE 添加连接以保持您的代码有效。 If you need adding line breaks to your strings for better readability, turn your string literals into template literals by changing quotes to backticks.
如果您需要在字符串中添加换行符以提高可读性,请通过将引号更改为反引号将字符串文字转换为模板文字。 This can be done using intention available on
Alt+Enter
:这可以使用
Alt+Enter
上可用的意图来完成:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.