是否存在vi的自动格式化工具,允许我根据语言首选项进行定义?
编辑:我不是在寻找语法高亮.我正在寻找将格式规则应用于我的代码的东西.(如支撑定位,oeprator周围的空间等)
我大部分时间都使用astyle来格式化我的代码,我很喜欢它,但有一个烦恼是它无法为最大行长度指定至少一个"提示".如果您有一行代码,例如:
this->mButtonCancel->setLeftClickProc(boost::bind(&FileListDialog::cancelLeftClick, this));
Run Code Online (Sandbox Code Playgroud)
我希望源代码格式化程序能够适度地智能地包装它:
this->mButtonCancel->setLeftClickProc(
boost::bind(&FileListDialog::cancelLeftClick, this));
Run Code Online (Sandbox Code Playgroud)
...可能是我如何格式化这行代码.对于长参数列表,我可能更喜欢在开括号上对齐,但显然在这种情况下不起作用.无论哪种方式,astyle都不支持使用不包含多个语句的长行执行任何操作.有谁知道一个工具呢?
给定一个包含错误缩进的源文件,不正确的空白区域管理等等.如何重新格式化代码这样的文件并应用Ruby的样式指南(如果存在)?
我对HTML的最大抱怨是换行符在元素之间增加了一点点空间.(jsFiddle.)
这可能会破坏子元素大小完全适合父母的布局.
我在某处读到你可以删除这个隐式填充 - 同时仍然保持代码有些清晰 - 通过使用这样的注释:
<!--
--><div>Foo</div><!--
--><div>Bar</div><!--
--><div>And so on...</div><!--
-->
Run Code Online (Sandbox Code Playgroud)
这有效,但我觉得必须有一个更好的解决方案.还有什么方法可以解决断线填充问题?
我使用了“重新格式化代码”选项,但它拒绝将代码格式化为我的自定义设置。我已经更改了新模板中的“代码样式”设置,并且正在使用它。无法在全局级别上更改代码样式。
它继续像这样格式化我的代码:
if (x) {
y();
}
Run Code Online (Sandbox Code Playgroud)
它应该看起来像这样:
if (x)
{
y();
}
Run Code Online (Sandbox Code Playgroud)
有什么想法吗?只是为了确认我已进入设置并更改了项目的自定义模板中的代码样式。我没有看到 IDE 设置的全局代码样式选项。
从7.x升级到8.x后,我发现了一个恼人的新"功能".当在空行上(按下回车键后),然后按退格键(用于去除插入符号前面的缩进字符)时,行将被删除,插入符号跳回到上面一行的末尾.
给出以下代码段和插入符号:
按下Backspace这样做:
我怎么关掉这个?
我想在 intelliJ 中按包对导入进行分组。
现在它对导入进行了正确的排序,并给了我这个。
import com.google.common.Something
import com.google.common.SomethingElse
import org.apache.commons.Something
import org.apache.commons.SomethingElse
Run Code Online (Sandbox Code Playgroud)
我希望它是
import com.google.common.Something
import com.google.common.SomethingElse
import org.apache.commons.Something
import org.apache.commons.SomethingElse
Run Code Online (Sandbox Code Playgroud)
我怎样才能让 intelliJ 自动执行此操作,而不必在Editor->Cody Style->Java->Imports->Import Layout.
我无法想象Android Studio如何foreach通过将它放在两行上来处理实时模板的样式:
for ( :
) {
}
Run Code Online (Sandbox Code Playgroud)
Editor -> Live templates -> Android -> foreach我们可以根据样式取消选择Reformat并且它保持在一行但它看起来像一个临时修复.我想找到where(according to style),以便能够修改它.谢谢
foreach android code-formatting intellij-idea android-studio
How do I prevent Visual Studio Code from pushing chained JavaScript functions on to a new line as can be seen illustrated by the GIF below:
As you can see, it makes the code extremely hard to view and extends a simple if check in to multiple lines. I am using the extension called Prettier - Code Formatter and I have looked through the preferences and found the following:
// Format a file on save. A formatter must be available, …Run Code Online (Sandbox Code Playgroud) 当前状态:
我有一个使用以下工具构建的项目:Java 1.8.161、Maven 3.3.9、SpringBoot 2.0.1,工具:Jenkins 和 GitLab。我想使用google java 格式作为整个团队的标准。
我的调查/解决方案:
在调查过程中,我找到了解决方案,这听起来很简单。只需使用以下命令更新 pom 文件:
<build>
<plugins>
<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
它有效。如果我运行编译、打包、验证、安装或部署 Maven 生命周期,代码将被格式化。
题:
我如何在所有团队成员每次提交后运行它,而无需在他们的 IDEA 中执行任何额外步骤?因为现在,我需要在每次提交之前运行 Maven。但是在应用程序运行过程中没有必要,所以团队可以避免它..这当然会导致git中的历史问题。
code-formatting ×10
ide ×2
java ×2
android ×1
c++ ×1
command-line ×1
foreach ×1
formatting ×1
git ×1
html ×1
javascript ×1
layout ×1
maven ×1
phpstorm ×1
ruby ×1
settings ×1
vi ×1
vim ×1