Unlike many people who are looking for this, or a similar sort of feature, it's not actually the file size I care about, I just find myself needing to deal with a very specific section of a file - maybe a couple hundred lines or less, so typically more than what fits on a screen at a reasonable font size.

One thought that I considered is creating a couple of marks, yanking that section, editing in a new split or tab, and then putting the edited text back.

That's kind of a hack, though, and doesn't make it so I can easily just save the text and run a command.

Manual folding could work for me, if I could make it so searches skip over the folds and they never open without a zO or something.

Is there any kind of way to edit a partial file in vim like that, or would I have to resort to some sweet hacks?

1 Answer 1


You could try the terrific NarrwRgn plugin by our very own Christian Brabandt, which has always worked very well for me.

Just select the lines you're interested in in visual mode, and then type :NR to open a new buffer containing just that area. Any changes you :write in the new buffer will appear instantly in the original, and you can simply close it when you're done: :q.

  • Hot dang that's fantastic. Pretty much exactly what I wanted! Apr 3, 2019 at 0:39
  • 1
    Thansk for mentioning my plugin ;) Apr 3, 2019 at 20:49
  • 1
    @ChristianBrabandt It's a great plugin!
    – Rich
    Apr 4, 2019 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.