Intellij Idea多行变量的javascript格式

Intellij Idea javascript formatting for multi-line var

本文关键字:javascript 格式 变量 Idea Intellij      更新时间:2023-09-26

所以我花了大量时间试图让intellij中的javascript代码样式Options实现我想要的功能,但还没有找到解决方案。如果我有多个vars声明,并有这样的评论

var obj = {
  a: 1,
  b: 2,
  c: 'three',
  value1: 'abc',
  // This is the comment about the. next var
  value3: 'four;

然后我格式化代码,最后使用

var obj = {
  a: 1,
  b: 2,
  c: 'three',
  value1: 'abc',
// This is the comment about the next var
  value3: 'four;

有什么可以保留评论缩进的吗?我在链接函数上看到了类似的行为

angular.module('aModule', [])
  /**
   * This is a controller
   */
  .controller('MyCtrl', function($scope) {
    $scope = [1,2,3];
  });

格式化文件

angular.module('aModule', [])
/**
 * This is a controller
 */
  .controller('MyCtrl', function($scope) {
    $scope = [1,2,3];
  });

我正在使用intellij Idea 13。谢谢

Project Settings-Code Style-JavaScript-Wrapping and Braces-检查Comment at first column