-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap width customization #305
Comments
The word wrap width should automatically adjust to the terminal's width. If it's not, something odd might be going on.
|
@gAmUssA Thank you for your feedback. Another possibility (I think):
|
Sorry to bother a long-closed issue, yet I am not satisfied about resolution.
───────┬────────────────────────────────────────────────────────────────────────
│ File: diary.md
───────┼────────────────────────────────────────────────────────────────────────
8 │ # 2017-09-16 суббота
9 │
10 │ Dictatorship is another way of defining a leader who doesn't dance to U <-- U is expected to be
│ S tune these days, how about focusing on your president first. on this very line
11 │ https://twitter.com/badowsky1/status/909017928682663941
───────┴──────────────────────────────────────────────────────────────────────── |
Unfortunately, |
To elaborate on what @sharkdp said, Word wrapping is kind of a complex issue with source code. While Consider Python: def my_function():
return "some" + "long line" As a human, I know it's safe to break it at the def my_function():
return "some" +
"long line" The The former is a massive maintenance burden, and would probably be better off as it's own project (e.g. a Rust-based alternative to The latter would just break the code, potentially misleading the person reading it: def my_function():
return "some" + "long
line" Unless some newer format of |
@sergeevabc, if you need a solution specifically tailored to |
What? I provided an example with no code. And asked about a switch, non a default behavior. Also, there is obvious implementation that exists for ages — break input at spaces as follows ; mimics bat --terminal-width 80
$ fold -w 80 lorem.txt
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor i
ncididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostru
d exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aut
e irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat n
ulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
; pay attention to -s, which activates “break at spaces mode”
$ fold -w 80 -s lorem.txt
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum. At present, I pipe it to |
@sergeevabc I fully agree that this would be nice to have. There's even a library for Rust that does "minimum raggedness" wrapping (a la Maybe we should reconsider this. It would be great if we could open a new ticket for that though. |
@sharkdp I kinda have a related but opposite question, but am not sure whether I should create a new issue: bat currently seems to implement a GFM-style markdown rendering rather than commonmark: it will keep the existing (single) line breaks of the original document rather than filling to the screen and only adding paragraph break. D'ya think it'd be possible to opt into "unrapping" paragraphs? |
@masklinn It would be great if you could open a new ticket with a detailed description. Thank you! |
@sergeevabc |
Hey @masklinn, it just so happens that I've implemented that kind of functionality in https://crates.io/crates/textwrap, see the
Currently, Textwrap takes a line of text (a paragraph) as input and returns a I have no idea of the internals of Infact, this makes me think that I should include a Textwrap example which simply reads lines from |
Just run fold -s README.md | bat --language=md Convenience function: batw() {
local f="$1"
fold -s "$f" | bat --language="${f##*.}" "${@:2}"
} Another alternative: batw() {
local f="$1"
local d="$(mktemp -d)"
fold -s "$f" > "$d/$f"
bat "$d/$f"
rm "$d/$f"
rm -d "$d"
} |
Still no switch to break input text at spaces? |
hello
Quick question: Is there a way to customize word wrap width?
It looks like by default it uses 80 characters with which is to low for my use cases (when I run iTem2 in the external monitor I have a little bit more real estate.)
Thank you
The text was updated successfully, but these errors were encountered: