I want to toggle open a specific file to a pane to the right


#1

I want a keybinding that basically does the following:
Toggle open a specific file to a pane to the right.

This file lies under ~/ADrive/my.todo and is not in the same directory as the project open.

This is what I’m currently doing. manually.

  1. Open the file with advanced-open-file
  2. Press cmd-k right to copy the file to a pane to the right.
  3. Switch back to the first pane to close the file cmd-w.
  4. Switch to the right pane again.

If the above is automated with a keybinding / macro. I want the following to happen if i press the same keybinding again:

  1. Close file in right pane.
  2. Then close right pane.

Now this I might be able to automate the first part with macro’s.
However since I want the same keybinding to do the reverse aswell I don’t really know how to do it.

Does anyone here have any ideas? Is it possible to toggle with a keybinding?

Any help is appreciated!


#2

Yes. You just need to decide on a way for your command to tell whether the todo file is open or not.

As for automating the open command, try this in your init.coffee file:

atom.commands.add 'atom-workspace', 'custom:open-todo', ->
  atom.workspace.open '~/ADrive/my.todo', {split: 'right'}

#3

Thank you for your answer

But that command actually opens a empty file in "/path/to/my/project/~/ADrive/my.todo"
I mean if I can check if right pane is open, and use that as the toggle variable. Use that.


#4

I got the path working by using the full path