Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript Ace editor spaces turns into tabs?

I'm using ace editor with these settings:

    ace.getSession().setTabSize(2);
    ace.getSession().setUseSoftTabs(true);
    ace.getSession().setUseWrapMode(true);

Whenever I press space it automatically indents it by 2. I only want it to indent by 2 spaces when I press tab, but 1 space when I press space. How do I fix it? Thanks.

like image 822
Harry Avatar asked Oct 17 '25 16:10

Harry


1 Answers

There may be another setting in your code that is causing this, consider the following 2 code examples ::

var editor = ace.edit("editor");
editor.session.setOptions({ tabSize: 2, useSoftTabs: true });
#editor {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js"></script>
<div id="editor"></div>

var editor = ace.edit("editor");
editor.session.setOptions({ tabSize: 8, useSoftTabs: true });
#editor {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js"></script>
<div id="editor"></div>
like image 75
Jesse Avatar answered Oct 19 '25 07:10

Jesse