# Sessions, folding and sticky scroll in Skink

> Skink reopens your files, splits and shells when you run it in a project again. Fold code with Alt+M, unfold all with Alt+Shift+M, sticky scroll and rulers.

Source: https://skink.cc/editing/sessions-and-folding/

Run `skink` with no arguments inside a project and it reopens what you had when you last quit there: files, cursors, split panes, the file tree and shells.

For folding, press Alt+M (or `:fold`) to fold or unfold the block at the cursor, and Alt+Shift+M (or `:unfoldall`) to open every fold.

## Restore your last session

A project is a folder with `.git`, `Cargo.toml`, `package.json`, `go.mod`, `pyproject.toml` or `build.zig`, or any folder below one. Running `skink` with no arguments there restores:

- the open files and their cursors
- split panes
- the file tree and its open folders
- shells, started again in their last folder (programs that were running in them are not restarted)
- extra roots added with `:addroot`

### Start fresh without losing the session

Opening a specific file or folder (`skink src/main.rs`, `skink .`) starts fresh and does not overwrite the saved session. So you can do a quick edit without losing your setup.

### Turn sessions off

```json
{ "restoresession": false }
```

### Unsaved work after a crash

Separate from sessions, Skink backs up unsaved edits after a 3 second pause. If Skink or the terminal crashes, opening the file again offers (r)ecover or (d)iscard.

## Fold code

Folding works by indentation, so it works in any language.

| Key | Typed command | Does |
|---|---|---|
| Alt+M | `:fold` | Fold or unfold the block at the cursor |
| | `:foldall` | Fold every top-level block |
| Alt+Shift+M | `:unfoldall` | Open every fold |

A closed fold shows a mark in the gutter (click it to open the fold) and "N lines" after its first line.

The cursor steps over a closed fold. Jumping into one, with search or go to line, opens it.

## Sticky scroll

The headers of the blocks you are scrolled into (the function, the `impl`, the class) stay pinned at the top of the editor. Click one to jump to it.

Turn it off with:

```json
{ "stickyscroll": false }
```

## Rulers

Draw vertical lines at given columns:

```json
{ "rulers": [80, 100] }
```

Micro's `"colorcolumn": 80` works too.

## Jump back and forward

Skink remembers where you were before a jump: go to definition, a result, quick open, `:goto`.

| Key | Typed command | Does |
|---|---|---|
| Alt+U | `:back` | Back to where you were before the jump |
| Alt+Shift+U | `:forward` | Forward again |

## Scrollbar marks

The scrollbar in the editor's last column marks, across the whole file:

- errors (red)
- warnings (yellow)
- find matches (orange)
- the cursor (blue)

## Multiple project roots

`:addroot DIR` adds another folder below the main root in the file tree. Quick open and project search cover it too, and the session remembers it.

`:removeroot [DIR]` removes it again. Without an argument it removes the one selected in the tree.

**Note:**
Skink is alpha. Folding is by indentation only for now; folds from tree-sitter syntax are not in yet, and neither is soft wrap.
