Simultaneously edit the same TextBuffer


#1

Given I have a blank TextEditor instance along with a File reference, how do I check if there is a TextEditor instance already editing the same File, and if so, use that same buffer so that that edits appear in both buffer simultaneously (similar to the behavior you get when splitting the pain on the same file).


#2

Use atom.workspace.observeTextEditors to see each one. Then check each against textEditor.getPath().

Doesn’t this already happen by default?


#3

atom.workspace.observeTextEditors gets the exact TextEditor instance, so if I take it’s view and put it in a new panel, it gets moved from its current position. What I’m trying to do is to make a copy of the TextEditor so that both can coexist and edit the same file, with changes showing in both views. Is this possible short of just doing a clone of the TextEditor object or something?


#4

What does the split pane code do? Will that work for what you want?


#5

Ok got it figured out.

textEditor = atom.workspace.getActiveTextEditor().copy()

Will get you a copy of the active editor that you can append to any panel / pane you like and get my desired behavior. Thanks @leedohm for the suggestion, found it in the pane.coffee code.