Note, the following command may or may not be valid, depending on your particular installation.
From man less
.
| <m> shell-command
<m> represents any mark letter. Pipes a section of the input file to the
given shell command. The section of the file to be piped is between the
first line on the current screen and the position marked by the letter.
<m> may also be ^ or $ to indicate beginning or end of file respectively.
If <m> is . or newline, the current screen is piped.
So when opened a file in less
, navigate to the desired position and type the following:
|. cat >filename
|.
causes less
to pipe the current screen to the given command. The command is cat >filename
. cat
reads from STDIN
and redirects to filename
.
You can also open the part within an editor if you want:
|. vi -
The -
causes vi
to read from STDIN
. Then in vi
edit whatever you want to edit and save the file with :w filename
. You can also use another editor, that can read from STDIN
.