問題描述
我有以下代碼:
DSPOTTGuaranteedUserReachForecastModel 模型 = 新的 DSPOTTGuaranteedUserReachForecastModel(模擬緩存,要求,mockTargetingDatabaseHelper,程序類型,地區);
正確的縮進應該是每個不完整行的兩個縮進.理想情況下,我希望我的文本編輯器像這樣格式化我的代碼:
DSPOTTGuaranteedUserReachForecastModel 模型 = 新的 DSPOTTGuaranteedUserReachForecastModel(模擬緩存,要求,mockTargetingDatabaseHelper,程序類型,地區);
但是,當我嘗試使用 VSCode 對其進行格式化時,我將所有新行合并成一個長行.
DSPOTTGuaranteedUserReachForecastModel 模型 = 新的 DSPOTTGuaranteedUserReachForecastModel(mockCache, 需求,mockTargetingDatabaseHelper,programType,區域);
有誰知道保留行號的規則的名稱是什么?
關于java格式化,
I have the following code:
DSPOTTGuaranteedUserReachForecastModel model = new DSPOTTGuaranteedUserReachForecastModel(
mockCache,
demand,
mockTargetingDatabaseHelper,
programType,
region);
The correct indentation should be two indents for each incomplete line. Ideally I would want to my text editor to format my code as such:
DSPOTTGuaranteedUserReachForecastModel model = new DSPOTTGuaranteedUserReachForecastModel(
mockCache,
demand,
mockTargetingDatabaseHelper,
programType,
region);
However, when I try to format it using VSCode, I am getting all the new lines collapsing into one long line instead.
DSPOTTGuaranteedUserReachForecastModel model = new DSPOTTGuaranteedUserReachForecastModel(mockCache, demand,
mockTargetingDatabaseHelper, programType, region);
Does anyone know what is the name of the rule for preserving line numbers?
About java formatting, VSCode-Java provides an Eclipse formatter file like Google Style.
The setting you wanted should be something like java_method_parameters_wrap = split_into_lines
, but unfortunately it's not included in GoogleStyle.xml.
If you're still interested in java formatting, you may figure it out in DefaultCodeFormatterOptions.
[EDIT]
Download googlestyle.xml and edit the following settings:
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="1" />
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
Then in vscode settings.json, set
"java.format.settings.url": "<local path to java-google-style.xml>",
You can get the formatting style that you want:
這篇關于Java 格式化:保留行但修復縮進的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!