Edit: Narrow to Region

edit.narrowToRegion

Restrict the buffer to the selection; the rest stays in the file but is out of reach.

How to run it

Open the command palette and search for Edit: Narrow to Region, then press Enter. The palette opens with M-x in Emacs, Ctrl+Shift+P in CUA, Sublime Text and VS Code, and Ctrl+Shift+A in IntelliJ IDEA (⇧⌘P and ⇧⌘A on macOS). It also has a default keybinding:

KeymapWindows / LinuxmacOS
EmacsC-xnnC-xnn

See also