Jer*_*emy 5 code-formatting intellij-idea
我正在一个Java项目中,在IntelliJ中有一些严格的代码格式要求。我发现很难理解首选格式,以至于损害了我的效率,并且无法轻松地查看自己的代码。
我正在寻找是否可以存储可以应用于我的代码的两种不同的代码格式配置或配置文件的方法。例如,我想在实现和调试期间将代码格式化为“我的样式”,然后在提交之前将其格式化为“公司样式”。我需要在多个提交中使用相同的代码,因此我需要随意从一种格式转换为另一种格式。
这可能吗?
企业风格,许多换行和空格:
private boolean scpLocalToRemote (String localIP, String remoteIP, String remoteUser,
String localFilePath, String remoteFilePath) {
String scpCommand = "scp " + localFilePath + " " + remoteUser + "@[" + remoteIP + "]:"
+ remoteFilePath;
log.info("SCP Command: '" + scpCommand + "'");
try {
MyProjectInterfaceUtils.runCommand(scpCommand);
} catch (IOException e) {
log.severe(e.toString());
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
我的风格(这是一种开发偏爱,不寻求有关格式化最佳实践的建议):
private boolean scpLocalToRemote(String localIP, String remoteIP, String remoteUser, localFilePath, String remoteFilePath)
{
String scpCommand = "scp " + localFilePath + " " + remoteUser + "@[" + remoteIP + "]:" + remoteFilePath;
log.info("SCP Command: '" + scpCommand + "'");
try
{
MyProjectInterfaceUtils.runCommand(scpCommand);
}
catch(IOException e)
{
log.severe(e.toString());
return false;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
1)在Ctrl+ Alt+ S\xe2\x86\x92 Code Style 中创建不同的代码样式(您可能需要复制(复制)更改后的方案并重命名)。
\n\n2) 按Ctrl+ `、2、 然后按与您的方案相对应的数字。
\n\n3) 应用++Ctrl重新格式化当前文件。AltL
\n| 归档时间: |
|
| 查看次数: |
60 次 |
| 最近记录: |