Is there a way for the Ace editor to preserve indentation upon a newline?
Would be helpful for editing a YAML or Python, 开发者_如何学JAVAfor example.
Indentation preservation is configured in the language mode (see f.e. getNextLineIndent
), if you don't have this it probably is due to no language mode selected. Change the language mode by:
<script src="src/mode-python.js" type="text/javascript" charset="utf-8"></script>
<script>
var PythonMode = require("ace/mode/python").Mode;
editor.getSession().setMode(new PythonMode());
</script>
To get syntax highlighting and auto-indent.
精彩评论