ace editor基本使用方法

去除中間的豎線:editor.renderer.setShowGutter(false);

去除行號:          editor.setShowPrintMargin(false);

設置並獲取內容:

editor.setValue("the new text here");

editor.session.setValue("the new text here"); // set value and reset undo history

editor.getValue(); // or session.getValue

設置主題: editor.setTheme("ace/theme/xcode");

設置語言模式: editor.session.setMode("ace/mode/sql");

啓用提示菜單:

    ace.require("ace/ext/language_tools");

    editor.setOptions({

        enableBasicAutocompletion: true,

        enableSnippets: true,

        enableLiveAutocompletion: true

    });

撤銷:editor.undo();

重做回退:editor.redo();

光標跳轉到指定行:editor.gotoLine();

查找替換:editor.execCommand('replace');

自動換行:editor.setOption("wrap", "free"); //關閉時free換成off

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章