Skip to main content
edited images for clarity
Source Link
user123992
user123992

When skimming through a file with less, I'm able to see all lines just fine.

When I do a search and then go for the next result with n, sometimes a highlighted result is shown on the top line, and sometimes there's nothing highlighted at all. This puzzled and annoyed me, so I did some experimentation.

What I found is that, when less gets search results on a line that would be wrapped, it is instead displaying the line following the search result, and not displaying the result line at all. In the image below, for example, it displayed the blue-highlighted "Contact Load..." line at the top of the page.

The missing search resultMissing search result

If I use up arrow to go look for the missing line, the search result still doesn't appear. Instead, less double-displays the top line.

If, however, I use down arrow to get the first line off the top of the screen, then use up arrow to return to where it was, poof! My missing search result suddenly appears.

enter image description hereSearch result showing

I've got my work-around, but my question is 1) why is this happening, and 2) is there some less startup flag I can use to avoid it?

In case it helps diagnose the problem, I'm running less -NFRW

When skimming through a file with less, I'm able to see all lines just fine.

When I do a search and then go for the next result with n, sometimes a highlighted result is shown on the top line, and sometimes there's nothing highlighted at all. This puzzled and annoyed me, so I did some experimentation.

What I found is that, when less gets search results on a line that would be wrapped, it is instead displaying the line following the search result, and not displaying the result line at all. In the image below, for example, it displayed the blue-highlighted "Contact Load..." line at the top of the page.

The missing search result

If I use up arrow to go look for the missing line, the search result still doesn't appear. Instead, less double-displays the top line.

If, however, I use down arrow to get the first line off the top of the screen, then use up arrow to return to where it was, poof! My missing search result suddenly appears.

enter image description here

I've got my work-around, but my question is 1) why is this happening, and 2) is there some less startup flag I can use to avoid it?

In case it helps diagnose the problem, I'm running less -NFRW

When skimming through a file with less, I'm able to see all lines just fine.

When I do a search and then go for the next result with n, sometimes a highlighted result is shown on the top line, and sometimes there's nothing highlighted at all. This puzzled and annoyed me, so I did some experimentation.

What I found is that, when less gets search results on a line that would be wrapped, it is instead displaying the line following the search result, and not displaying the result line at all. In the image below, for example, it displayed the blue-highlighted "Contact Load..." line at the top of the page.

Missing search result

If I use up arrow to go look for the missing line, the search result still doesn't appear. Instead, less double-displays the top line.

If, however, I use down arrow to get the first line off the top of the screen, then use up arrow to return to where it was, poof! My missing search result suddenly appears.

Search result showing

I've got my work-around, but my question is 1) why is this happening, and 2) is there some less startup flag I can use to avoid it?

In case it helps diagnose the problem, I'm running less -NFRW

Source Link
user123992
user123992

Why do less search result lines disappear/reappear?

When skimming through a file with less, I'm able to see all lines just fine.

When I do a search and then go for the next result with n, sometimes a highlighted result is shown on the top line, and sometimes there's nothing highlighted at all. This puzzled and annoyed me, so I did some experimentation.

What I found is that, when less gets search results on a line that would be wrapped, it is instead displaying the line following the search result, and not displaying the result line at all. In the image below, for example, it displayed the blue-highlighted "Contact Load..." line at the top of the page.

The missing search result

If I use up arrow to go look for the missing line, the search result still doesn't appear. Instead, less double-displays the top line.

If, however, I use down arrow to get the first line off the top of the screen, then use up arrow to return to where it was, poof! My missing search result suddenly appears.

enter image description here

I've got my work-around, but my question is 1) why is this happening, and 2) is there some less startup flag I can use to avoid it?

In case it helps diagnose the problem, I'm running less -NFRW