Write to File and Open in Editor


#1

Hello,
I’m relatively new to developing packages for Atom editor. I was hoping someone could answer a question for me. My question is this: how can you write to a file with Atom and open it? I know how to get the filepath, but I need a way of getting just the directory and finding a way to write a new file to it.

Thanks! If this is a duplicate (which I don’t think it is), can you kindly link me to it?


#2

Sounds like you’re asking for this:


#3

So, for writing files I HIGHLY recommend fsPlus. You can install it using apm install fsPlus or the better way is to add it to your package.json dependencies and run apm update. To see the available methods, check out the source.

For opening a file in the editor you can use atom.workspace.open(path). Docs: Workspace.open()


#4

Ah ok, I misunderstood the question … sorry about that! Carry on :laughing:


#5

Awesome thank you for your quick response!