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

Allow like grep -B: Show lines before a match #144

Closed
jidanni opened this issue Mar 30, 2021 · 2 comments
Closed

Allow like grep -B: Show lines before a match #144

jidanni opened this issue Mar 30, 2021 · 2 comments

Comments

@jidanni
Copy link

jidanni commented Mar 30, 2021

In Less 551,

       n      Repeat  previous  search, for N-th line containing the last pat‐
              tern.  If the previous search was modified by ^N, the search  is
              made  for the N-th line NOT containing the pattern.  If the pre‐
              vious search was modified by ^E, the  search  continues  in  the
              next  (or  previous)  file if not satisfied in the current file.
              If the previous search was modified by ^R, the  search  is  done
              without  using  regular  expressions.  There is no effect if the
              previous search was modified by ^F or ^K.

is great, except that it always puts the matched line at the top of the
screen. Let's say we are looking at
$ less +/longlat/ epsg.txt

# Unknown datum based upon the Bessel Namibia ellipsoid
<4006> +proj=longlat +ellps=bess_nam +no_defs  <>
# Unknown datum based upon the Clarke 1858 ellipsoid
<4007> +proj=longlat +a=6378293.645208759 +b=6356617.987679838 +no_defs  <>
# Unknown datum based upon the Clarke 1866 ellipsoid
<4008> +proj=longlat +ellps=clrk66 +no_defs  <>
# Unknown datum based upon the Clarke 1866 Michigan ellipsoid
<4009> +proj=longlat +a=6378450.047548896 +b=6356826.621488444 +no_defs  <>
...

Well we need a CLI parameter to always show us one line above the match,
so we can read the comment that belongs to the match.

@gwsw
Copy link
Owner

gwsw commented Mar 30, 2021

Doesn't the -j option do what you are asking for?

@jidanni jidanni closed this as completed Mar 31, 2021
@jidanni
Copy link
Author

jidanni commented Apr 4, 2021

By the way, maybe mention on the man page that "...thus -j 0 and -j 1 are no-ops.
The real action begins at -j 2."

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

2 participants