ACE 是一个开源的、独立的、基于浏览器的代码编辑器,可以嵌入到任何web页面或JavaScript应用程序中。ACE支持超过60种语言语法高亮,并能够处理代码多达400万行的大型文档。ACE开发团队称,ACE在性能和功能上可以媲美本地代码编辑器(如Sublime Text、TextMate和Vim等)。
ACE是Mozilla Skywriter(以前称为Bespin)项目的继任者,并作为Cloud9的主要在线编辑器。
以下是它的详细特性:
使用引导部分翻译可能有部分歧义,请谅解,最初接触是因为liferay的aui团队使用了,我想提取出来,看了源码发现是另外一个叫ace的开源框架,没事就找了找,转出来分享下。
ACE是Mozilla Skywriter(以前称为Bespin)项目的继任者,并作为Cloud9的主要在线编辑器。
以下是它的详细特性:
- 可以对60多种语言进行语法着色(可以导入TextMate/Sublime/.tmlanguage 文件)
- 20多种主题(可以导入TextMate/Sublime/.tmtheme文件)
- 自动缩进,减少缩进
- 一个可选的命令行
- 处理巨大的文件,可以处理4,000,000行代码
- 完全自定义的键绑定,包括V正则表达式搜索和替换
- 高亮匹配括号
- 软标签和真正的标签之间切换
- 显示隐藏的字符
- 用鼠标拖放文本
- 换行
- 代码折叠
- 多个光标和选择
- 实时语法检查器(支持 JavaScript/CoffeeScript/CSS/XQuery)
- 剪切,复制和粘贴功能IM和Emacs模式
- git clone git://github.com/ajaxorg/ace.git
- var ace = require("lib/ace");
- editor.setTheme("ace/theme/twilight");
- editor.getSession().setMode("ace/mode/javascript");
- editor.setValue("the new text here"); // or session.setValue
- editor.getValue(); // or session.getValue
- editor.session.getTextRange(editor.getSelectionRange());
- editor.insert("Something cool");
- editor.selection.getCursor();
- editor.gotoLine(lineNumber);
- editor.session.getLength();
- editor.getSession().setTabSize(4);
- editor.getSession().setUseSoftTabs(true);
- document.getElementById('editor').style.fontSize='12px';
- editor.getSession().setUseWrapMode(true);
- editor.setHighlightActiveLine(false);
- editor.setShowPrintMargin(false);
- editor.setReadOnly(true); // false to make it editable
- editor.resize();
- editor.find('needle',{
- backwards: false,
- wrap: false,
- caseSensitive: false,
- wholeWord: false,
- regExp: false
- });
- editor.findNext();
- editor.findPrevious();
- editor.find('foo');
- editor.replace('bar');
- editor.replaceAll('bar');
- editor.getSession().on('change', function(e) {
- // e.type, etc
- });
- editor.getSession().selection.on('changeSelection', function(e) {
- });
- editor.getSession().selection.on('changeCursor', function(e) {
- });
- editor.commands.addCommand({
- name: 'myCommand',
- bindKey: {win: 'Ctrl-M', mac: 'Command-M'},
- exec: function(editor) {
- //...
- },
- readOnly: true // 如果不需要使用只读模式,这里设置false
- });
使用引导部分翻译可能有部分歧义,请谅解,最初接触是因为liferay的aui团队使用了,我想提取出来,看了源码发现是另外一个叫ace的开源框架,没事就找了找,转出来分享下。
收藏的用户(0) X
正在加载信息~
推荐阅读
最新回复 (0)
站点信息
- 文章2302
- 用户1336
- 访客11053564
每日一句
Youth means limitless possibilities.
年轻就有无限的可能。
年轻就有无限的可能。
新会员