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

[RFE] always show buffer content on start when pattern specified via CLI matches nothing #135

Open
ryenus opened this issue Mar 10, 2021 · 2 comments

Comments

@ryenus
Copy link
Contributor

ryenus commented Mar 10, 2021

Version: less 580

Currently, in case the search pattern is passed via the command line options, and if there's no match, like the case with the following command:

echo abc | less +/d

In this case, upon starting, less doesn't show the buffer content, namely abc in this case, instead it only displays the error message:

Pattern not found (press RETURN)

It would be better that the buffer content is also made visible before the above error message is dismissed.

@cben
Copy link

cben commented Jan 24, 2023

Same with less --pattern=foo (which is really alias for +/foo).

workarounds I discovered:

  • Pressing RETURN proceeds to show the file content. (Same as "Pattern not found" message behaves after interactive search — just less obvious if the message is all you see at first... I mean, it says "press RETURN" right there in the message, but it hadn't occurred to me 🙈)
  • less +r --pattern=foo — r does repaint. It may still show "Pattern not found", but at least you'll see (the first screen of) the text.
  • if your goal of searching is highlighting, not movement, try less +r --pattern='foo|$'. The |$ makes it match the empty string at end of any line, preventing "Pattern not found" (except on entirely empty file). Naturally, it breaks the n/p keys as every line will match.

I still wish paint-before-message was default behavior.

@ryenus
Copy link
Contributor Author

ryenus commented May 21, 2024

  • less +r --pattern=foo — r does repaint. It may still show "Pattern not found", but at least you'll see (the first screen of) the text.

^This does the trick for me, thank you so much @cben 👍

Naturally, it breaks the n/p keys as every line will match.

Edit: however matching every line and break n/N feels like another deal breaker 😂

@ryenus ryenus changed the title always show buffer content on start even if pattern specified via CLI matches nothing [RFE] always show buffer content on start even if pattern specified via CLI matches nothing May 21, 2024
@ryenus ryenus changed the title [RFE] always show buffer content on start even if pattern specified via CLI matches nothing [RFE] always show buffer content on start when pattern specified via CLI matches nothing May 21, 2024
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