Skip to content
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

Q: Toggle line numbers on and off while viewing - is it possible? [ANSWER: not right now] #2474

Closed
HenrikBengtsson opened this issue Feb 8, 2023 · 6 comments
Labels
question Further information is requested

Comments

@HenrikBengtsson
Copy link

HenrikBengtsson commented Feb 8, 2023

Question

Is it possible to toggle line numbers on and off while viewing a file? (This would be useful if you ever need to cut'n'paste a few lines from a file)

Here is what I've tried

Entering -p

Given that

bat -p README.md

suppresses line numbers, I though entering -p would toggle them, but instead I get an error:

Cannot change the -p (--pattern) option  (press ENTER)

Looks like CLI option -p is overridden by an in-viewer option.

Entering -n or -N

I view a file with:

bat README.md

which decorates each line with a line number. Then, when I type -n, while viewing, there is a message saying:

Don't use line numbers  (press ENTER)

Here, I expect/hope that bat would re-render the file and display the file without line numbers. FWIW, if I type -n again, then it says:

Use line numbers  (press ENTER)

Entering -n will keep switching between these two messages, but there is no visual difference AFAICT.

I also tried -N, but no effect.

Session info

$ bat --version
bat 0.22.1 (e5d9579)
henrik@hb-x1-2023:~/repositories/ansible-hb-x1-20
@HenrikBengtsson HenrikBengtsson added the question Further information is requested label Feb 8, 2023
@thexeromin
Copy link

Currently, there is no way to toggle line numbers.

@thexeromin
Copy link

@sharkdp I would love to add a PR for this. Should I?

@keith-hall
Copy link
Collaborator

See also #1053

@sharkdp
Copy link
Owner

sharkdp commented Feb 10, 2023

@sharkdp I would love to add a PR for this. Should I?

I don't think it's possible to implement this right now without fundamentally changing how we interact with the pager. As @keith-hall mentioned, please see #1053.

@sharkdp
Copy link
Owner

sharkdp commented Feb 10, 2023

This is also related to #1177. Closing for now.

@sharkdp sharkdp closed this as completed Feb 10, 2023
@HenrikBengtsson
Copy link
Author

Thanks for the quick comments and answers

@HenrikBengtsson HenrikBengtsson changed the title Q: Toggle line numbers on and off while viewing - is it possible? Q: Toggle line numbers on and off while viewing - is it possible? [ANSWER: not right now] Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants