Add `bat --wrap word`
The current --wrap character behavior
echo Lorem ipsum dolor sit a met, \
consectetur adipiscing elit. \
Nullam venenatis nec est \
eu tristique \
| bat --decorations=never \
--paging=never \
--language bash \
--theme Nord \
--color=always \
--terminal-width 11 \
--wrap character \
-
Suggestion
I suggest a new word mode for the --wrap option, which will split lines only by spaces (except in cases where a word is too long for a single line). These spaces should then be stripped
An example of how it should look with --wrap word:
Issue #2751 is related and this comment also provides a shell workaround.
@einfachIrgendwer0815, unfortunately, this workaround will break syntax highlighting, which goes completely against the initial purpose of using bat for syntax highlighting:
echo Lorem ipsum dolor sit a met, \
consectetur adipiscing elit. \
Nullam venenatis nec est \
eu tristique \
| bat -p \
| fold -w 12 -s \
| bat --decorations=never \
--paging=never \
--language bash \
--theme Nord \
--color=always \
-
Ok, I just have found a better workaround that works in my case:
echo Lorem ipsum dolor sit a met, \
consectetur adipiscing elit. \
Nullam venenatis nec est \
eu tristique \
| fold -w 12 -s \
`# replace newlines by unique` \
`# invisible character that ` \
`# is ignored by syntax ` \
`# highlighting ` \
| sed -zE "s/\n/\x2062/g" \
| bat --decorations=never \
--paging=never \
--language bash \
--theme Nord \
--color=always \
- \
`# revert it back ` \
| sed -zE "s/\x2062/\n/g"
would love to see this feature implemented as well. using bat to make man pages more readable is great but not having an option to soft wrap or word wrap makes it less readable than it otherwise could be. less has this feature but of course, once the man pages get passed through bat for man syntax highlighting, it ignores/remove this formatting.