Not a task for less
No,
I do not think you can do that directly, because less does not have a cursor to begin with.
It would need one to navigate to start and end of the text to select.
less
is just not the right tool for character-level navigation.
Tabs already expanded
You can use the key shift and the mouse to make a selection; This is handled by the terminal, not by less. But the terminal does not know how spaces and tabs where arranged - less does the interpretation of tabs internally, and writes only normal "
" characters to the screen.
There are tools like screen
, tmux
and byobu
, which can do lots of impressive things in this area.
I did not check, but I assume that these terminal multiplexers do not have a way around that - being terminals, in the end - and will behave the same.
Use vim
If you are showing a file in less
, there is a nice solution:
Press the key v in less
to open the current file in vim
- asuming your $EDITOR
etc. is set up for vim
.
This does not work when showing stdin from a pipeline or so, although there are workarounds.
Mouse scrolling, at least
But you can at least scroll with the mouse wheel:
That seems even to be enabled by default, but the mouse wheel events get suppressed by a different option.
For a quick test, try:
LESS=-r man less
The option -X
(--no-init
) blocks scrolling - check what your environment variable LESS
contains:
$ echo $LESS
The option -q
(--quiet
, --silent
) also causes trouble, according to SU: How to make mouse wheel scroll the less pager using bash and gnome-terminal?
w3m can be a decent pager (though I do prefer less). It supports the mouse (you may need to enable this in the configuration), including scrolling.
Vim is a text editor but can be used as a pager: set PAGER='vim -R'
. You can enable mouse support with set mouse=a
in your ~/.vimrc
. The wheel works at least in xterm, I can't vouch for OSX's terminal emulator.
Best Answer
Actually it uses whatever is specified in the
MANPAGER
or thePAGER
environment variable.Depending on your
man
implementation and version there could be also a command line switch to specify the pager.With the man-db implementation I use all the below ways work:
To set it permanently, just add it to your
~/.bashrc
(or other initialization file used by your shell):That works with some older
man
implementations too, whileMANOPT
is man-db specific:(Better do not set
PAGER
that way. That one is used by many other applications too.)There could be also a global configuration file. man-db has
/etc/man_db.conf
or/etc/manpath.config
. There you can set:But unfortunately that is taken in consideration only if neither
MANPAGER
norPAGER
is set.