- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
git diff --ignore-space-at-eol --ignore-space-change --ignore-all-space
你得到零差异线。我想避免格式化代码变得更糟的情况,这样人们就可以避免在未来尝试通过 clang-format 之类的东西来改进我们的代码库。在我们的例子中,至少我们可以就纯空格达成一致,制表符是 4 个空格。所以只改进缩进只能是一件好事。
Eclipse 具有“纠正缩进”的功能(通过菜单 --> 源代码 --> 纠正缩进):
Eclipse 的“正确缩进”只是缩进,但它不是 shell 命令,我想要/需要一个 shell 命令,以便我可以在所有源代码文件上运行该命令。
例如只有空格,4 个空格。
最佳答案
Clang-format 始终使用默认格式。您可以自定义它。如果您不指定样式,则会选择 clang-format 默认值。 [1],[2]
不幸的是,您不一定只修复缩进。
在对您的问题的评论中,KamilCuk 建议使用 indent
可能指的是 https://www.gnu.org/software/indent/
我考虑过配置一个只做缩进的自定义样式,但是不幸的是,在检查样式选项时,有一些可能会改变代码库,具体取决于它的外观,比如 AllowShortIfStatementsOnASingleLine
这不允许共存
if (a)
return ;
else {
return;
}
if (b) return ;
else {
return;
}
因此,您可能会找到适用于您的代码库的特定配置,但这将非常具体且脆弱。
[1]
The configuration file can consist of several sections each having different Language: parameter denoting the programming language this section of the configuration is targeted at. See the description of the Language option below for the list of supported languages. The first section may have no language set, it will set the default style options for all lanugages. Configuration sections for specific language will override options set in the default section.
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#configuring-style-with-clang-format
[2]
This section lists the supported style options. Value type is specified for each option. For enumeration types possible values are specified both as a C++ enumeration member (with a prefix, e.g. LS_Auto), and as a value usable in the configuration (without a prefix: Auto).
BasedOnStyle (string)The style used for all options not specifically set in the configuration.
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#configurable-format-style-options
关于c++ - 有没有办法使用 clang-format 来做 "indentation only"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64805558/
这很奇怪,我只是在变量设置中进行了更改以使用哈希代替......你知道: black = #000 替换为: colors = { 'black': #000 // and so o
这很奇怪,我只是在变量设置中进行了更改以使用哈希代替......你知道: black = #000 替换为: colors = { 'black': #000 // and so o
我有这行代码,在测试 pep8 错误时我得到:线太长。因此,为了尝试解决此问题,我使用了 slash('\') 但随后我将延续行过度缩进以进行视觉缩进。我该怎么做才能解决这个问题? 我尝试过的事情:
我在下面的代码中收到一个 continuation line under-indented for visual indent 错误: command = 'ffmpeg -i downloa
我就是想不通这是怎么回事…… #!/usr/bin/env python # # Bugs.py # from __future__ import division # No
我是一个 Emacs 用户,在配置编辑器方面没有任何技能。我从 haskell-mode 升级后从 2.4 到 2.7,我注意到两个变化: 缩进在某种程度上是不同的,在某种程度上我不太喜欢。我不能完全
我正在尝试制作一个嗅探DNS数据包的程序,然后将数据包的qname放入字典的“键”中,并将数据包的dst ip放入字典的“值”中,由于某种原因,我遇到了此错误在第6行 from scapy.all
为了进行比较: 在Sublime(以及Atom)中,如果我在已经有4个制表符空间的代码行下按Tab,Sublime将自动跳到上一行的相同制表符间距(4个制表符空间)。 在VS Code中,当尝试完成相
无论我以哪种方式编写以下函数都会引发错误。 @staticmethod def _generate_clone_spec(param1=None, p
我正在 Sublime 文本编辑器中使用 Python。我被添加PEP8 packages . 我将 128 添加到以下文件“pep8_ignore”中。添加128并保存后。 Preferences
我从这里得到了 Google java 风格: https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style
刚刚使用 Sublime Text(使用 Sublime Linter)打开了一个文件,并注意到我以前从未见过的 PEP8 格式错误。正文如下: urlpatterns = patterns('',
我已安装 google-java-format插件 IntelliJ我已经启用了插件。当我格式化代码时,我的 java 代码缩进了 2 个空格。如何将 google java 格式化程序插件设置更改为
Haskell Parsec 的 indents 包提供了一种解析缩进式语言(如 Haskell 和 Python)的方法。它重新定义了 Parser类型,那么如何使用 Parsec 的 Text.P
我想让我的代码更有条理。因此,每当我从我的functions.php 文件中复制一个函数并将其粘贴到一个类中时,我需要将函数的每一行缩进一次或多次,以便于阅读并且看起来更美观。我的一些函数只不过是巨大
我直接从教科书中复制了这个 block ,并收到许多错误消息,但我无法解决其中的任何一个。我已经阅读并重读了我书中的这一部分,据我所知,这都是一个 block ,所以我很困惑为什么会有意外的缩进。我将
我直接从教科书中复制了这个 block ,并收到许多错误消息,但我无法解决其中的任何一个。我已经阅读并重读了我书中的这一部分,据我所知,这都是一个 block ,所以我很困惑为什么会有意外的缩进。我将
我一直在尝试找到一种也适合回溯缩进的递归下降解析器算法。但我一直让自己为此寻找麻烦的解决方案。 是否有任何资源也可以处理缩进? 谢谢 最佳答案 根据您的问题,我假设您正在为缩进敏感语言编写自己的递归下
有时,当我在 Sublime text2 中编辑 coffeescript 文件时,将其编译为 js 时出现错误: error: unexpected INDENT
我的main.sass中有这个: #thing { -moz-box-sizing: border-box; -webkit-box-sizing: border
我是一名优秀的程序员,十分优秀!