问题描述
限时送ChatGPT账号..我想知道使用ace编辑器是否可以隐藏编辑器的某些行内容.
I would like to know if using ace editor is possible to hide some lines of the content of the editor.
特别是我有兴趣隐藏一些行,例如:
In particular I am interested in hiding some lines like:
%Some Tag 有助于在编辑器中查找特定代码块
%Some Tag useful to find particular chunk of code in the editor
示例:
BEGIN My theory
%Block:Function id:tick
Myfunction() {}
END
我一直在使用标签(%...)来帮助自己找到Myfunction() {} ,因为我需要修改代码的特定部分.因此,我不会向用户显示该行,但我会将其用作标签,以便将其保留在编辑器的内容中.我不能使用像行数这样的引用,因为它可能会改变.
I have been using The tag ( %...) to help myself to find Myfunction() {} , because I need to modify that particular part of code. So, I wouldn't show that line to the user, but I would use it as tag so keeping it in the content of the editor. I cannot use reference like the number of row because it may change.
谢谢
推荐答案
可以使用 addFold
you can use addFold
var Range=require("ace/range").Range;
editor.session.addFold("", new Range(1,0,2,0))
addFold 的第一个参数是占位符文本,第二个参数是要隐藏的范围
first argument to addFold is the placeholder text and the second one is the range which you want to hide
这篇关于使用 ACE 编辑器隐藏一些行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论