I have a couple of imperfect, but maybe useful, ideas.
Method 1 - mousey.
Use the terminal scrollbar.
xterm; adjustments will be required for other terminals.)
- Enable the scrollbar if it isn't already. (In
xterm, it's in the menu you get with Ctrl+Button2.)
- Make sure
less is not running with the
-c option (I have this option enabled in my
LESS environment variable, but it interferes with what we're about to do, so I have to type
-c to turn it off.)
- Using whatever
less commands you like, scroll up or down so the first line you want to copy is visible on the screen.
- triple-Button1 your chosen starting line to select it.
- Scroll down until the last line you want to copy is visible on the screen. You must use only the space bar or other simple scrolling keys, not a
/ search - the point here is to get
less to send all the lines to the terminal so they can be copied.
- Button3 on your chosen end line to extend the selection.
Possible difficulty: your scrollback buffer may not be big enough. That can be changed in
xterm with the
saveLines resource or
-sl command line option, but I don't know of a way to change it in an xterm that's already running.
Method 2 - non-mousey.
| (pipe) command in
less to send the text to
- Using whatever
less commands you like, scroll up or down to position the last line you want to copy at the top of the screen. You can skip this step and the next step if you want to copy all the way to the end.
- Use the
m (mark) command to set a mark at your chosen end position. Marks are a useful feature by themselves, and you should know them already from
vi, but just in case you don't: mx sets a mark, where the
x can be any letter, and 'x returns you there later.
- Now scroll up so the first line you want to copy is at the top of the screen.
- Use the pipe command: |x which will bring up a prompt for you to enter an external command. The
x should be the same mark letter you used in the
m command, or
$ for "all the way to the end". Type
The simple case of copying the entire man page reduces to g|$xclipEnter.
Warning (i.e. the horrible thing that just happened to me):
xclip will be semi-backgrounded, running as part of the
less process group. If you try to suspend
less, start another job on the same terminal, and paste into it, it will not work. Then when you later foreground the
less job, suddenly the paste will come through. I think this should be considered an