• ace-editor


    1. ace-editor编辑器只读状态:editor.setReadOnly(true);  // false to make it editable
    2. ace-editor设置程序语言模式:editor.session.setMode("");
    3. ace-editor获取光标所在行列:editor.selection.getCursor();
    4. ace-editor跳转至行:editor.gotoLine(lineNumber);
    5. ace-editor设置默认制表符大小:editor.session.setTabSize(4);
    6. ace-editor使用软标签:editor.session.setUseSoftTabs(true);
    7. ace-editor设置字体大小:document.getElementById('editor').style.fontSize='12px';
    8. ace-editor设置代码折叠:editor.session.setUseWrapMode(true);
    9. ace-editor设置高亮:editor.setHighlightActiveLine(false);
    10. ace-editor是否显示中间的垂直中线(打印边距可见度):editor.setShowPrintMargin(false);
    11. 搜索:
    editor.find('needle', {
      backwards: false,
      wrap: false,
      caseSensitive: false,
      wholeWord: false,
      regExp: false
    });
     editor.findNext();
        editor.findPrevious();
     
    下列选项可用于您的搜索参数:
    needle: 要查找的字符串或正则表达式
    backwards: 是否反向搜索,默认为false
    wrap: 搜索到文档底部是否回到顶端,默认为false
    caseSensitive: 是否匹配大小写搜索,默认为false
    wholeWord: 是否匹配整个单词搜素,默认为false
    range: 搜索范围,要搜素整个文档则设置为空
    regExp: 搜索内容是否是正则表达式,默认为false
    start: 搜索起始位置
    skipCurrent: 是否不搜索当前行,默认为false
    
    替换单个字符:
    editor.find('foo');
    editor.replace('bar');
     
     
    替换多个字符:
    editor.replaceAll('bar');
    editor.replaceAll使用前需要先调用editor.find(‘needle’, …)
     
    12. 事件监听
    监听事件 onchange
    editor.session.on('change', function(delta) {
    // delta.start, delta.end, delta.lines, delta.action
    });
    监听事件 selection 
    editor.session.selection.on('changeSelection', function(e) {
    });
    监听事件 cursor 
    editor.session.selection.on('changeCursor', function(e) {
    });
     
     
     
    13. 添加新命令以及绑定键盘按键
    需要将指定键绑定到一个自定义函数:
    editor.commands.addCommand({
      name: 'myCommand',
      bindKey: { win: 'Ctrl-M', mac: 'Command-M' },
      exec: function (editor) {
        //...
      },
      readOnly: true // false if this command should not apply in readOnly mode
    }); 
     
  • 相关阅读:
    mapreduce参数记录
    find命令使用中记录
    运算符的优先级(从高到低)
    常用字符与ASCII代码对照表
    mysql在liunx上使用记录
    Java 流收集器 ( Stream Collectors )
    CDH 删除Agent节点(退役节点)
    学习记录CombineFileInputFormat类
    读取HBases的数据的三种常见用法
    hash算法学习
  • 原文地址:https://www.cnblogs.com/scale/p/11983241.html
Copyright © 2020-2023  润新知