Search code examples
javascriptword-wrapace-editor

Remove word-wrap offset in ACE editor


I need to remove offseting 4 " " which are automatically created after breaking line in ACE editor

I tried using editor.setTabSize(0) that worked as well, but then I can't ident code by using TAB, as it throws "undefined" instead into code. I searched on ACE webpage, but there is nothing as that, and when searched forums, it told something with setBehaviosrEnabled, but that didn't work either

Any idea how to get rid of those 4 spaces?

Issue: enter image description here

Code:

var editor = ace.edit("edittext");
editor.setOptions({
    maxLines: Infinity
});
editor.getSession().setUseWrapMode(true);
editor.setBehavioursEnabled(false);
editor.renderer.setOption('showLineNumbers', false);
editor.setTheme("ace/theme/xcode");

Solution

  • This is controlled by indentedSoftWrap setting in ace, you cn turn it off by running

    editor.setOption("indentedSoftWrap", false);
    

    behaviours setting is completely unrelated and controls automatic insertion of closing brackets and tags.

    So your code from the above would become

    var editor = ace.edit("edittext");
    editor.setOptions({
        maxLines: Infinity,  // this is going to be very slow on large documents
        useWrapMode: true,   // wrap text to view
        indentedSoftWrap: false, 
        behavioursEnabled: false, // disable autopairing of brackets and tags
        showLineNumbers: false, // hide the gutter
        theme: "ace/theme/xcode"
    });