A quick tip for those working with some large files in Vim.

If you’ve been wondering about how you can quickly save what’s under your current selection (ctrl + v or anything like that - visual mode), this one is for you.

First, select the content you want using the visual selection.

Then submit the current selection to tee so that it can take the contents from the selection from its stdin and then write back to two places:

  1. stdout (replacing the current selection with the same thing), and
  2. a file of your choice (so that the file gets saved).

The illustrated version of what happens is the following:

Example of using Tee together with Vim

That’s it!

If you have any questions, please let me know!

I’m @cirowrc on Twitter.

Have a good one!