Skip to content

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

@n1vux

Description

@n1vux

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions