ACE编辑器显示空白区域

6 html javascript editor ace-editor

我在HTML上使用ACE编辑器,我在我的网站上设计了一个自定义模式来突出显示语法,认为语法识别和突出显示一切都很好,我无法找到显示白色空格和制表空间的方法喜欢崇高的文字.

在搜索时,我知道我们可以使用

getNextLineIndent(state, line, tab) { }

作为检查每个新行中事件的计数器.

除了这个解决方案有没有任何默认或简单的选择?

a u*_*ser 13

使用editor.setOption("showInvisibles",true)


Tyl*_*ong 7

editor.setShowInvisibles(true);


小智 -6

终于想通了!

可以通过以下步骤显示空白(就像在 sublime text 中一样):

  1. 打开 ace.js
  2. 搜索单词 无形者
  3. 在第 14499 行,替换为以下代码

     this.showInvisibles = true;
     this.setShowInvisibles = function(showInvisibles) 
     {
          if (this.showInvisibles == showInvisibles)
          return true;
          this.showInvisibles = showInvisibles;
          this.$computeTabString();
          return true;
    };
    
    Run Code Online (Sandbox Code Playgroud)
  4. 保存并刷新浏览器,所有空白都会显示。
  5. 您也可以类似地切换其他可用选项。