标签: code-formatting

Visual Studio代码格式

我已经使用Visual Studio作为我的主要IDE一段时间了(尽管我仍然使用Emacs进行一些个人项目).

我喜欢Emacs格式化C/C++代码的方式,我想说服Visual Studio对C#代码使用类似的约定.例如,在Emacs中,C函数调用如下所示:

functionName(argument1,
             argument2,
             argument3);
Run Code Online (Sandbox Code Playgroud)

在Visual Studio格式化的C#代码中,函数调用如下所示:

functionName(argument1,
    argument2,
    argument3);
Run Code Online (Sandbox Code Playgroud)

这对我来说似乎更糟糕.

有没有办法调整Visual Studio代码格式规则?任何可以处理的插件?

非常感谢,

code-formatting visual-studio

12
推荐指数
2
解决办法
2万
查看次数

如何使用Method :: Signatures使Perltidy工作?

我正在使用Eclipse与EPIC结合来编写我的Perl代码.我将EPIC配置为使用Perltidy和"-pbp"(perl最佳实践样式)来格式化我的代码.

使用Method :: Signatures的命名参数时,这不起作用.例如,func (:$arg1, : $arg2)格式化为func (: $arg1, : $arg2)产生错误.

此外,func关键字不被识别,sub因此缩进是错误的.

有关此之前的悬而未决的问题和这个跨岗位.

eclipse perl code-formatting method-signature perl-tidy

12
推荐指数
1
解决办法
780
查看次数

格式化传递给Java中的函数的多个参数

通常,传递给函数的参数数量可能很大.考虑以下情况:

calculate(dataManager.getLastUpdate().getNumberOfChildren(),
          dataManager.getLastUpdate().getNumberOfParents(),
          dataManager.getLastUpdate().getNumberOfGrandChildren(),
          long milliseconds,
          int somethingelse)
Run Code Online (Sandbox Code Playgroud)

是否有一个指南Java可以提供一种方法来协调论点?在一行中拟合所有参数看起来不太漂亮.

java formatting code-formatting

12
推荐指数
3
解决办法
2万
查看次数

为什么COBOL必须缩进?

为什么COBOL必须缩进,因为在每个源文件中都有额外的间距?

考虑这段代码(注意额外的空格):

  IDENTIFICATION DIVISION.
  PROGRAM-ID. HELLO-WORLD.
  PROCEDURE DIVISION.
      DISPLAY 'Hello, world'.
      STOP RUN.
Run Code Online (Sandbox Code Playgroud)

在Fortran代码中可以看到类似的格式:

   program hello
      print *, "Hello World!"
   end program hello
Run Code Online (Sandbox Code Playgroud)

但为什么COBOL和Fortran需要这个空白?什么原因?

cobol fortran code-formatting

12
推荐指数
1
解决办法
5675
查看次数

是否可以使用pgAdmin4自动格式化/美化SQL查询?

我想直接在pgAdmin4中autoformat /美化我的SQL查询.我从Eclipse中开发Java知道这个功能,我可以使用一个简单的快捷方式来美化整个代码.

到目前为止,我只找到了一个命令行解决方案,使我的SQL查询非常漂亮:pgFormatter.

postgresql code-formatting pgadmin-4

12
推荐指数
3
解决办法
4634
查看次数

寻找Java代码美化(或者可能没有美化,但是让代码更优雅的东西)

我不知道如何描述它,但我正在寻找一种工具,可以为我的代码提供关于如何...更优雅的建议.

例如,使嵌套的if()语句成为switch语句.这样的事情.由于我不知道如何描述我的问题,我不知道该搜索什么.我的东西代码美化不要专门改变陈述吧?

java code-formatting

11
推荐指数
1
解决办法
1583
查看次数

JSLint,else和预期'}'和'else'错误之间只有一个空格

为什么JSLint在代码中报告:

function cos(a) {
    var b = 0;
    if (a) {
        b = 1;
    }
    else {
        b = 2;
    }

    return b;
}
Run Code Online (Sandbox Code Playgroud)

错误:

Problem at line 6 character 5: Expected exactly one space between '}' and 'else'.
Run Code Online (Sandbox Code Playgroud)

可以通过禁用JSLint的Tolerate messy white space选项来关闭此错误.

或者换句话说 - 为什么语法: } else {更好

...
}
else {
...
Run Code Online (Sandbox Code Playgroud)

Google还使用} else {表单语法.

但我不明白为什么.谷歌提到"隐含的分号插入",但在开放的背景下{,不是关闭一个.

JavaScript可以关闭后插入分号}的if,即使下一个标记是块else指令?

对不起,我的问题有点乱 - 我试着大声思考.

javascript code-formatting jslint

11
推荐指数
2
解决办法
1万
查看次数

C++的自动代码样式指南测试

可能重复:
根据一组编码标准检查C/C++源代码的免费工具?

我正在开始一个涉及我无法直接访问的几个人的c ++项目.我们就编码风格指南达成了一致意见,例如根据可访问性定义了班级成员的外壳(即帕尔卡案中的私人情况,骆驼案中的公众和受保护人.请不要开始讨论风格指南.我已经足够了.谢谢.).

我现在要做的是生成一些样式指南违规报告.我不想强制执行样式指南,例如在提交时,但我想提供一个工具,每个开发人员可以使用它来查看他/她的代码违反样式指南的位置(如果他/她想要检查它).

你知道一个可以做这项工作的工具吗?

(它需要能够理解一些C++,例如检测类成员的可访问性.)

c++ code-formatting

11
推荐指数
1
解决办法
1万
查看次数

在Visual Studio中将多行代码格式化为单行

是否有键盘快捷方式或快速方法将以下代码更改为Visual Studio 2013中的单行?我也安装了Resharper.

多

new XElement("Option",
            new XAttribute("Name", "FileDelete"),
            "1"
        ),
Run Code Online (Sandbox Code Playgroud)

单

new XElement("Option", new XAttribute("Name", "FileDelete"),"1" ),
Run Code Online (Sandbox Code Playgroud)

resharper code-formatting keyboard-shortcuts visual-studio visual-studio-2013

11
推荐指数
4
解决办法
1万
查看次数

Is there a comprehensive C# linter and formatter like eslint for JS/TS?

I'd like to have my C# projects (.NET Core 3.1+) to be linted and formatted on each build both locally and in CI environment. I know that there's new .NET Analyzers feature and dotnet-format tool in .NET 6, but I can't understand from the documentation if I can make a single comprehensive configuration file that both these tools would use so I can enforce certain code style in my team. Could you help me understand if it is possible?

.net c# lint code-formatting

11
推荐指数
1
解决办法
1万
查看次数