Regex Line Filter

approved

by 64mm4-kn1f3

Filter a note with regex so that only lines that match are displayed.

9 stars773 downloadsUpdated 8mo agoApache-2.0

Regex Line Filter plugin for Obsidian

image

Version 1.3.5

Purpose:

The plugin allows users to filter the active editor view in Obsidian so that only lines matching a user-supplied regular expression are displayed. Users can edit these visible lines. Toggling the filter off restores the full view of the note with the edits preserved. Toggling it back on re-prompts for a regex (pre-filled with the last used one).

Key Features:

  • Regex Filtering: Filters the current note based on a JavaScript-compatible regex (including emoji support).

  • Hotkey Assignable Custom Filters: Create custom filters and assign individual hotkeys to them. Toggling multiple custom filters will allow for incremental additive/subtractive filter output.

  • Live Editing: Allows editing of the filtered (visible) lines directly. Edits are saved to the actual note.

  • Toggle Command: Provides a command palette action (and assignable hotkey) to toggle the filter on/off.

  • Regex Input Modal: A clean modal prompts for the regex when activating the filter.

  • Persistent History: Remembers the last 5 unique regex strings used across sessions and displays them as pinable/saveable entries in the input modal for quick reuse.

  • Template Date Variables: Use relative dates in your filters. Eg {{date:YYYY-MM-DD}} or {{today}} for the current date, {{yesterday}}, {{last-month}}, {{last-year}}, {{tomorrow}}, {{next-month}} and {{next-year}}.

  • Empty Line Handling: Includes a setting to choose whether empty lines (containing only whitespace) should also be hidden when the filter is active (defaults to true).

  • **Visual Indicator:**Adds a subtle darkening effect (inset box-shadow) to the editor margins when the filter is active, providing clear visual feedback.

  • Child indents: Child indents will be included in an active filter by default. This behaviour can be disabled in plugin settings if desired.

  • Copying filtered text: Selecting across filtered lines then copying will copy only the visible lines to clipboard. This default behaviuor can be disabled in plugin settings.

Known Limitations:
  • Negative lookaheads: Possible issue with negative lookaheads in regex.

How To:

image

Demo showing a number of regex filters used with the plugin assigned to a HotKey.

Thank You:

  • To SkepticMystic for the inspiration for saveable individual filters in your Advanced Cursors plugin.
  • To FelipeRearden, stef-rausch and nanjingman for the feature suggestions!

License: Apache 2.0


Buy Me A Coffee

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.