Lines Cleaner
pendingby Piotr Tkaczyk
Remove or clean lines containing specific markers in file or selection with configurable backup options.
Lines Cleaner - Obsidian Plugin
A powerful Obsidian plugin that removes or cleans lines containing specific markers in file or selection with configurable backup options.
Usecases
Templated workflow
- Create templates with comments explaining the content or purpose of sections.
- Hint: Use embedded notes to add more complex content.
- Create new note from template and fill the parts as usual.
- Use this plugin to remove sections of the note along with the comments making note clean.
Note postprocessing
- Create a note with some draft content. Add comments to specify what needs to be done.
- Update draft content as needed.
- Use this plugin to remove the comments for finalized sections.
Features
- Range-Based Removal: Remove content between start and end markers while preserving partial line content
- Comment Cleaning: Remove %% comments %% from lines containing specific markers
- Link Cleaning: Convert Markdown links to backticked text while preserving other formatting
- Single Line Removal: Remove entire lines containing specific markers
- Empty Line Limiting: Control maximum consecutive empty lines between content
- Empty List Item Removal: Remove empty list items like "- ", "- [ ]", "- [x]"
- Multiple Access Methods: Ribbon button, context menus, and command palette
- Configurable Markers: Customize all removal strings in settings
- Automatic Backups: Optional backup creation with timestamp (
filename_HHmmss.ext) - Safe Operations: Confirmation notices and error handling
Usage
Access Methods
- Ribbon Button: Click the eraser icon in the left sidebar to clean the current active file
- File Context Menu: Right-click any file in the file explorer and select "Clean lines"
- Editor Context Menu: Right-click in the editor and select "Clean lines"
- Command Palette: Search for "Clean lines from current file"
Settings
Access plugin settings via Settings → Community Plugins → Lines Cleaner:
Feature Selection: Choose which cleaning features to enable. All features are enabled by default:
- Enable Range Removal: Remove content between start and end markers
- Enable Comment Cleaning: Remove specific %% comments %% containing markers
- Enable Link Cleaning: Convert links to plain text in backticks
- Enable Single Line Removal: Remove entire lines containing markers
- Enable Empty Line Limiting: Control consecutive empty lines between content
Range Removal:
- Range Start Markers: Text markers that begin content to remove. Enter one marker per line. (default:
%% remove from here %%andrm-from-here) - Range End Markers: Text markers that end content to remove. Enter one marker per line. (default:
%% remove till here %%andrm-till-here)
Comment Cleaning:
- Comment Cleaning Markers: Only comments containing any of these markers will be removed (markers must be inside the comments). Enter one marker per line. (default:
remove this commentandrm-cmt)
Link Cleaning:
- Link Cleaning Markers: Lines containing any of these strings will have their links converted to backticked text. Enter one marker per line. (default:
%% clean me %%andclean-ln)
Single Line Removal:
- Single Line Removal Markers: Lines containing any of these strings will be completely removed. Enter one marker per line. (default:
%% remove line %%andrem-ln)
Empty Line Limiting:
- Keep at most X consecutive empty lines: Control maximum consecutive empty lines (0-10). 0 = remove all empty lines, 1 = keep at most 1 empty line between content, etc. (default: 1)
List Item Cleaning:
- Remove empty list items: Remove lines containing only empty list items like "- ", "- [ ]", "- [x]", etc. (default: false)
Backup Options:
- Create Backup: Toggle automatic backup creation before modifications
Examples
Range Removal:
some text %% remove from here %%
line to remove
another line to remove
%% remove till here %% remaining text
more text rm-from-here
content to delete
rm-till-here final text
Result:
some text remaining text
more text final text
Comment Cleaning:
This text %% this comment stays %% has comments %% remove this comment %%
Another line %% inline comment %% with %% another comment rm-cmt %% text
More text %% keep this %% and %% rm-cmt delete this %% end
Result:
This text %% this comment stays %% has comments
Another line %% inline comment %% with text
More text %% keep this %% and end
Link Cleaning:
Check [[My Note]] and [Google](https://google.com) %% clean me %%
Another line with [[Another Note|Display]] clean-ln here
Normal line with [[Keep Link]] stays
Result:
Check `My Note` and `Google`
Another line with `Display` here
Normal line with [[Keep Link]] stays
Single Line Removal:
This line stays
%% remove line %% This entire line is removed
This line also stays
rem-ln Another line to remove
Final line stays
Result:
This line stays
This line also stays
Final line stays
Empty Line Limiting:
First paragraph
Second paragraph
Third paragraph
Result (with "Keep at most 1 consecutive empty line"):
First paragraph
Second paragraph
Third paragraph
Empty List Item Removal:
Task list:
- First task
-
- [ ]
- [x]
- Second task
- [ ] Third task
Result (with "Remove empty list items" enabled):
Task list:
- First task
- Second task
- [ ] Third task
Installation
From Obsidian Community Plugins (Recommended)
- Open Obsidian Settings
- Go to Community Plugins
- Search for "Lines Cleaner"
- Install and enable the plugin
Manual Installation
- Download the latest release files (
main.js,manifest.json,styles.css) - Create folder
VaultFolder/.obsidian/plugins/line-cleaner/ - Copy the files to this folder
- Reload Obsidian and enable the plugin
Development
Building
npm install
npm run build
Development Mode
npm run dev
License
MIT License - see LICENSE file for details.
Support
If you find this plugin helpful, consider supporting its development!
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.