Skip to content

Feature request: client-side row filtering (like less "&") - #272

Open
lvbuwei wants to merge 1 commit into
okbob:masterfrom
lvbuwei:feature/row-filter
Open

lvbuwei wants to merge 1 commit into
okbob:masterfrom
lvbuwei:feature/row-filter

Conversation

@lvbuwei

@lvbuwei lvbuwei commented Oct 1, 2026

Copy link
Copy Markdown

I'd like to propose a small feature: client-side row filtering.

Motivation

When inspecting wide tables (e.g. \d+ output, CSV, or query results),
it is often useful to temporarily hide every row that does not match a
substring, to focus on the rows of interest. The less pager offers
exactly this with its & command.

Proposed behavior

  • Pressing & prompts for a substring (same prompt UX as the / search).
  • Only data rows that contain the substring stay visible; non-matching
    rows are hidden. The header, footer and corner windows stay intact.
  • Cursor navigation (j / k / g / G) moves between matching rows.
  • An empty pattern (press & then Enter) clears the filter and restores
    all rows.
  • Matching honors the global ignore_case option.

Implementation

I have a working implementation ready. It:

  • adds a cmd_Filter command bound to & plus a "Filter rows" menu item,
  • stores the pattern in ScrDesc (so it survives re-layout),
  • makes window_fill skip non-matching data rows, deriving the row
    number and cursor position from the real line number so rownum/cursor
    stay in sync.

Known limitations:

  • Case handling follows ignore_case only (no smart-case
    ignore_lower_case heuristic like search).
  • When no row matches, the data area is shown empty with a
    "Pattern not found" notice; clear it with an empty pattern.

A patch is attached / a pull request is available if you are
interested. Would you be open to accepting such a feature?

Pressing & prompts for a substring and hides all data rows that do not contain it (similar to & filtering in less). This makes it easy to narrow down wide tables (e.g. \d+ output) to rows of interest.

- new cmd_Filter command bound to & and a Filter rows menu item

- filter pattern stored in ScrDesc and preserved across re-layout

- window_fill skips non-matching data rows while keeping the header and footer windows intact

- cursor navigation (j/k/g/G) jumps between matching rows

- an empty pattern clears the filter and restores all rows
@okbob

okbob commented Oct 14, 2026

Copy link
Copy Markdown
Owner

I am not against this feature, but I think it needs more thinking about cursor, and first row (on the screen) positioning. Your simple implementation can produce some unwanted visual artefacts. Probably it needs an alternative total_rows, and switching when filter is active. Everything should to work although the cursors can be invisible (deactivated).

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

Successfully merging this pull request may close these issues.

2 participants