Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append text to last line, ace editor

Tags:

ace-editor

I want to insert text to the last line of current content. It just like an append operation in file. I only find the editor.insert(text) method. This method add text right after the cursor. Is there any way just append the text to the last line?

like image 286
Ciel Avatar asked Oct 20 '25 20:10

Ciel


1 Answers

use editor.session.insert method to insert text at arbitrary position

var session = editor.session
session.insert({
   row: session.getLength(),
   column: 0
}, "\n" + text)
like image 146
a user Avatar answered Oct 24 '25 12:10

a user



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!