var editor = ace.edit("editor"); ace.require("ace/ext/language_tools"); editor.setTheme("ace/theme/twilight"); editor.getSession().setMode("ace/mode/javascript"); editor.getSession().setTabSize(4); editor.getSession().setUseWrapMode(true); editor.commands.addCommand({ name: 'editSave', bindKey: {win: 'Ctrl-S', mac: 'Command-S'}, exec: function(editor) { console.log(editor.getValue()); } }); editor.setDragDelay(10); editor.setFontSize(13); editor.on("change", function(e){ editor.commands.exec('startAutocomplete',editor); }) editor.setShowPrintMargin(false);//显示固定宽度 //自动补全 editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: true });