micro icon indicating copy to clipboard operation
micro copied to clipboard

Implement a new "quit"-like command that exits the editor but remembers all the open files, tabs, splitviews.

Open ghost opened this issue 9 years ago • 7 comments

Feature request: Implement a new command that exits the editor but remembers all the open files, tabs, splitviews, so that the next time the editor is fired up, it will automatically load the last session (discussion is what behavior to adopt for modified but unsaved files). This could be keymapped to something like Alt + Q or something in that area.

ghost avatar Oct 24 '16 10:10 ghost

Something like tmux detach/attach, would be nice to have (but I don't know how much work it will take)

mame98 avatar Oct 24 '16 11:10 mame98

Perhaps a .micro file that holds state inside your project folder? On my fork I am experimenting with saving state for my project. The first thing I have implemented is storing cursor positions.

jantb avatar Nov 17 '16 06:11 jantb

Being able to resume a previous session would be huge for productivity for those who have multiple tabs/views open so they wouldn't have to do it every time they open the editor.

Rather than having a different key binding when exiting I think it would be better if the state was stored by default and there could be a setting to open the last session.

$ micro --previous-session # opens last session $ micro /path/tofile --previous-session # open file in current tab and previous session as separate tabs

umairidris avatar Feb 26 '17 03:02 umairidris

@adrianvoica As long as it's alright for modified files not to be retained, this should be doable. Keeping modified but unsaved files is just impractical, but keeping a list of tabs and splits and the path of their buffers should be doable. Though it'd be a bit of a hassle for several reasons. ( What if files weren't opened with relative paths instead of absolute paths? Then restoring them from a different working directory wouldn't work. Also restoring splits would be much more difficult than restoring just tabs. What if micro is launched in a differently sized terminal? Could cause issues with restoring splits. )

I'm thinking the best way to do this if it is done at all, would to be to store a yaml file in the configuration directory. ( Also bear in mind that I'm writing this comment as much for my reference as in response to your request. ) Something like:

session:
  tabs:
    - 1:
      - /home/geiger/example.txt
    - 2:
      - /home/geiger/code.go
      - /home/geiger/code.go.old

But then that doesn't account for restoring the "correct" split layout. For example, what if I have three vertical splits and the last one is horizontally split? What if I have two horizontal splits and the bottom is vertically split? etc. There's no "easy" way to keep that information in a file. It'd also be kind of a hassle to get that information from the tree split system.

GeigerCounter avatar Mar 29 '17 07:03 GeigerCounter

hey, this would be super useful, is it dead already?

vakokako avatar Jun 18 '21 09:06 vakokako

This would be extremely useful personally I think it would be best if there was a setting for weather to remember tabs instead of you having to use some custom binding.

godalming123 avatar Nov 28 '21 18:11 godalming123

Having it able to behave like that would be great.

Malla-h avatar Jul 02 '24 05:07 Malla-h