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

FAQ or Cookbook -- Less Chop/Scroll (instead of wrapping) super-long-lines #138

Open
n1vux opened this issue May 1, 2024 · 0 comments
Open

Comments

@n1vux
Copy link
Contributor

n1vux commented May 1, 2024

re beyondgrep/ack3#234 and 325 (and ack2 rollover)

Better workaround for minified JS multi-screenful-lines that aren't properly named as ${file}.min.js so as ignorable, or that needs to be searched because one doesn't have the source JS, and other similarly very-very-long-line files that actually want to be searched :

Ack --pager='less --chop-long-lines -iR' will frequently hide the match instead of centering, but at least only uses one line for the many-thousand-char line with a match (or several). This Less Chop mode allows arrow-key and emacs scrolling, and provides reverse video > affordances at ends of lines to show which lines are cropped/scrollable. This is abbreviable as less -S.
ack-234-scroll-right-1
➔➔
ack-234-scroll-right-2

This option can be put this in ${HOME}/.ackrc as a default.

In $HOME/.ackrc, might want to include less option -F aka --quit-if-one-screen so that it DWIMishly emulates ack --nopager when vertical scroll isn't needed.

To try this out in a POSIX shell,

ACK_PAGER_COLOR='less -FSiR'  ; export ACK_PAGER_COLOR

less ...
-F or --quit-if-one-screen
Causes less to automatically exit if the entire file can
be displayed on the first screen.
-S or --chop-long-lines
Causes lines longer than the screen width to be chopped
(truncated) rather than wrapped. That is, the portion of
a long line that does not fit in the screen width is not
displayed until you press RIGHT-ARROW. The default is to
wrap long lines; that is, display the remainder on the
next line. See also the --wordwrap option.
--wordwrap
When the -S option is not in use, wrap each line at a
space or tab if possible, so that a word is not split
between two lines. The default is to wrap at any
character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant