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,784 times
2
Ed Doe
- 21
3 Answers
2
Put this in your .bashrc or similar configuration file.
export PAGER="/bin/sh -c \"fmt -s -w $(tput cols) - | less\""
phuclv
- 30,396
- 15
- 136
- 260
2
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
- 21
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