Copy a range of lines in Vim

I often have multiple terminal tabs open to completely different projects in vim, but because my vim shows line numbers, dots for whitespace, and indent lines, copy and pasting with the mouse doesn’t work all that well.

Sometimes I’ll just cat the file that I’m working on, but then I usually have to scroll quite a bit and find the specific lines that I want to copy.

If I use sed though I can get just the lines that I need using this command:

:!sed -n 23,31p filename

I often have to look up this sequence, so I’m going to see if I can turn it into a bash script that automatically adds it to my clipboard or maybe I can look into doing it with vim directly using shift+v when I select the lines that I want.