Skip to content

About

Hide text in a buffer to focus on the selected region. Emulates the emacs narrow to region functionality in the vim text editor.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

narrowText.vim 🔍

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.

Why use narrowText?

  • 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 .wide file on your next visit and offers a full restoration.
  • Auto-Widen: Safely restores and saves your full document whenever you :w or :q.

Installation

Use your favorite plugin manager:

Plug 'thetextsmith/narrow-text'

Lazy.nvim (neovim)

{ "thetextsmith/narrow-text" }

packer.nvim

use 'thetextsmith/narrow-text' 

Vim 8+ Native Packages

git clone https://github.com/thetextsmith/narrowText.git ~/.vim/plugins/start/narrow-text

Usage

Command Default Map Description
NarrowToSelection <leader>- Narrow to selection (Visual) or current line (normal)
Widen <leader>+ Widen, stitch edits, and save to disk

Customizing Maps

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)

Statusline Integration

Keep track of your narrowed state by adding %{narrowText#Status()} to your statusline:

set statusline+=%{narrowText#Status()}

About

Hide text in a buffer to focus on the selected region. Emulates the emacs narrow to region functionality in the vim text editor.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages