I use the Python package rtv as a terminal client to read Reddit. When it gets to a large text box, it calls less display the text. Currently, less wraps the words according to column width, meaning that sometimes you get cut off in the middle of the word. Is there a configuration or tweak that can make it only fold where there is whitespace?
Asked
Active
Viewed 1,360 times
2
Ed Doe
- 21
- 2
-
No. But you can ask the author for it at [link] (http://www.greenwoodsoftware.com/less/bugs.html) – matzeri Jul 21 '16 at 14:39
3 Answers
2
Put this in your .bashrc or similar configuration file.
export PAGER="/bin/sh -c \"fmt -s -w $(tput cols) - | less\""
ASaylover3156
- 21
- 2
-
-
Doesn’t make it on the fly but before calling `less`; this way `less` cannot react accordingly on window size changes, and you also cannot switch it on or off. A nice approach nevertheless. Not what I want, though. – Alfe Jul 03 '23 at 00:06
1
One solution is to use the -S (--chop-long-lines) command line option for less. This tells less to truncate lines to the width of the screen. To view the truncated lines that are wider than the terminal, the left and right arrow keys can be used to scroll the window horizontally.
You can enable this behavior by adding -S to the command line or setting the environment variable, LESS, like this in Bash:
$ export LESS='-S'
More on word wrapping can be found in this question: How to turn off word-wrap in less
Stephen Balousek
- 274
- 2
- 5
1
I use the unix toolbox for my terminal/bash viewer:
alias v='(fold -s -w75 | nl -bn -w10 | LESS= less -MINRz-4+G:1g)<'
sbin_bash
- 11
- 1
-
What does that do? How would one use it? Please do not respond in comments; [edit] your answer to make it clearer and more complete. – Scott - Слава Україні Dec 03 '18 at 20:25