# Files Changed Outside *Lx*

*Lx* watches open files for changes made by another program.

## Clean read-only files

A clean read-only document reloads automatically when its file changes.

This includes ordinary text views and Markdown previews. *Lx* keeps the visible position as closely as the viewer allows. A Markdown preview returns to the same source area.

Image and binary viewers refresh through their own reload path.

## Editable files

An editable document is not replaced without asking.

When its file changes on disk, *Lx* shows a notice. When you return to that document, you can choose:

- **Reload** to use the file from disk
- **Keep Current** to keep the copy already open in *Lx*

If the open document has unsaved changes, *Lx* asks again before discarding them.

## Deleted files

If an open file disappears, *Lx* shows a warning and keeps the open document.

The document is not silently cleared. If the file returns, *Lx* reports that it was restored.

## Reload by hand

Use these commands from the [Command Palette](command_palette.md):

| Command | Action |
| --- | --- |
| `doc:reload` | Reload the active file |
| `doc:reload-stale` | Reload every changed clean file |
| `doc:toggle-monitor` | Turn file watching on or off for this session |

`doc:reload` refuses to discard unsaved changes without confirmation.

## Change the monitoring settings

```lua
config.doc_monitor_enabled = true
config.doc_monitor_active_interval = 1.0
config.doc_monitor_passive_interval = 2.0
config.doc_monitor_prompt_on_focus = true
config.doc_monitor_notify_passive = true
```

- `doc_monitor_enabled` controls whether watching starts with *Lx*.
- `doc_monitor_active_interval` controls how often the active file is checked.
- `doc_monitor_passive_interval` controls how often background tabs are checked.
- `doc_monitor_prompt_on_focus` controls prompts for changed editable files.
- `doc_monitor_notify_passive` controls notices for changed background files.

Intervals are measured in seconds. Very short intervals cause more file-system work.
