narrowText.vim brings Emacs-style "narrow-to-region" to Vim with a focus on persistence and safety. Unlike standard folding, narrowText physically isolates your selection, moving the rest of the file into a hidden background file so you can work with zero distractions.
- Distraction-Free: Narrow your buffer to a single function or paragraph.
- Stitched Edits: New lines added while narrowed are seamlessly integrated back into the original file structure upon widening.
- Fail-Safe Recovery: If Vim crashes, the plugin detects the orphaned
.widefile on your next visit and offers a full restoration. - Auto-Widen: Safely restores and saves your full document whenever you
:wor:q.
Use your favorite plugin manager:
Plug 'thetextsmith/narrow-text'{ "thetextsmith/narrow-text" }use 'thetextsmith/narrow-text' git clone https://github.com/thetextsmith/narrowText.git ~/.vim/plugins/start/narrow-text| Command | Default Map | Description |
|---|---|---|
| NarrowToSelection | <leader>- |
Narrow to selection (Visual) or current line (normal) |
| Widen | <leader>+ |
Widen, stitch edits, and save to disk |
If you prefer different keys, add this to your .vimrc or init.lua:
map <YOUR-PREFERRED-KEYS> <Plug>(HideTextNarrow)
nmap <YOUR-PREFERRED-KEYS> <Plug>(HideTextWiden)Keep track of your narrowed state by adding %{narrowText#Status()} to your statusline:
set statusline+=%{narrowText#Status()}