Set Value for ace editor without selecting the whole editor
So you can set value of an ace editor with setValue
but after setting the value, the editor will select the whole value of the editor. How do you disable this? This mean when I set value of ace editor to Hello world
, it won't highlight Hello world
Solution 1:
You can use the second parameter to control cursor position after setValue
editor.setValue(str, -1) // moves cursor to the start
editor.setValue(str, 1) // moves cursor to the end
Solution 2:
You can even use clearSelection() after you do an setValue();
editor.setValue("Hello World");
editor.clearSelection(); // This will remove the highlight over the text
Solution 3:
This works for me!
editor.setValue(editor.getValue(), 1);