question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the best way to append / add text ?

See original GitHub issue

From what I understood from the doc Code Mirror as a textfield and a rich DOM mirror that the user see.

What is the best approach to append text or add a line ?

In the doc it look like replaceRange is the way to go.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
marijnhcommented, May 31, 2012

Right. Use lineCount to figure out the end of the document (or just use Infinity, since positions will be clipped to the existing document), and append your text.

editor.replaceRange("foo\n", {line: Infinity});

One potentially tricky issue is that if you want to ensure your text starts on a new line, you’ll have to prepend it with a \n if and only if the document doesn’t end with a newline. That’s app-specific, and I’ll leave it to you to figure it out.

0reactions
MasseGuillaumecommented, May 31, 2012

Ok Thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Append a String in Python – STR Appending - freeCodeCamp
Another way you can append strings in Python is by using the join() method. The join() method takes an iterable object — Lists,...
Read more >
3 Best Ways to Append to String in Python - AppDividend
The best way to append to a string in Python, use the += operator. We saw three approaches, but the best way is...
Read more >
How do I append one string to another in Python?
If you're just appending two strings then just use + . Share.
Read more >
Python String Append | DigitalOcean
Another way to perform string append operation is by creating a list and appending strings to the list. Then use string join() function...
Read more >
Python append to string - How is it done? | Flexiple Tutorials
It is very easy to append string in Python. Here, you will read about different ways to append string and which is the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found