Best way to create new TextEditor


Hey everyone! So I’m just starting out developing with Atom so forgive me if this is a rather easy question, but I’m trying to create a TextEditor view in a custom pane (Trying to make a package that emulates Bracket’s inline css-editor, although from what I’ve read, it’d be difficult to do it in-line so I’m just thinking of opening it in a bottom panel or something), and I was wondering what’s the best way to create a new TextEditor View instance? From my lurking, I found that the TextEditorView class was previously used, but the 1.0 docs are showing that its deprecated or at least, has a broken API Doc link.

What I’ve got so far:

te = document.createElement('atom-text-editor')

Although this only appears to create a view, and I believe I need to model in order to attach the associated TextBuffer I want in order to edit an actual file.

What is the proper way to create an atom-text-editor?

That’s one of the possible ways to create a text editor element, yes. To get the model, use

var te = document.createElement('atom-text-editor');
var model = te.getModel();


Ah okay awesome. Would you happen to know how to attach a TextBuffer to this new editor in order to edit a file?


As far as I know, you can just use model.setText('text here'); to set the text in the editor and it will be editable.


Just FYI since I tried the aforementioned method but without success, there is a function in the atom API that builds a TextEditor and I’ve found it to be very helpful: