New Plguin: Obsidian Text Finder

Because Obsidian’s “Find/Replace in current file” doesn’t quite meet my needs. So I decided to write a plug-in to improve my experience.

The plug-in is still in the development stage, but some basic functions have been completed, such as: find, replace, highlight, display the number of matches, support regular expressions, case sensitivity…
I think the appearance of the plug-in is also OK.
There should be no obvious problems in use at present, you can try it.
(via Google translate)
Text Finder

6 Likes

Thanks very much for making this and adding regex functionality.

2 Likes

Cool! Are you planning on global search/replace? That’s really the only reason I still have to use VScode sometimes. I’d love to get that function in Obsidian :slight_smile:

3 Likes

There is a global search and replace plugin but that never budged for me.

Also, mobile support would be nice as well (negative lookbehind regex might hinder it).

1 Like

I tried that one but it broke some notes. It deleted more than the regex should have, though it worked in vscode. So i deleted that plugin. I hope @hafuhafu won’t do that haha

Thanks for the suggestion.
At this stage, I mainly want to improve the “in the current file” feature.
Global search/replace currently does not seem to provide an available API in Obsidian.
But it seems that it can be implemented in some special way. Maybe I will start exploring it after the main features are stable :wink:.

2 Likes

Tried editing the manifest (“isDesktopOnly”: false); it worked second time as well. Good.

Cannot test on PC now but I cannot seem to use special regex character ^ on mobile, though. (No result.)

1 Like

Thanks for the feedback. I seem to have found the cause of the problem and I tried to fix it in version 0.1.3

1 Like

Thanks.
On with the testing. Found another hiccup:
New line character (\n) is taken as literal on replacement. \\n would be literal, right.

If I understand correctly: if you need to match a line break, use shift+enter to make the text wrap, and typing \n in the input box will only match the text \n.
linebreak

Sorry, I used Google Translate to do this conversation so it might be a little confusing.
All the input in the Replace field, except for the regular expression related $1, $2…, will be treated as text (string).
If you want to use line breaks on PC, you can use shift+enter to do it.
I tried typing a line break on my phone and it worked just by pressing enter.

I’ll have a look later.

Would you consider adding \n support on match and replacement side to these main features, though?

I tried it in VSCode and understood this feature. I will try to support this feature later.

1 Like

Thanks.
The strong suit of your plugin compared to the built-in find (and replace) is support for case sensitivity and regex. I was focusing on the regex capabilities, of course.

1 Like

Version 0.1.5 already supports the use of escape characters \n and \t in replacement. :grin:

1 Like

Thanks for updating the manifest with false as well.

But now on PC I cannot see this working…at all…?
Modal doesn’t pop up on any command.

Edit. Didn’t work on another vault, either first, then after a restart, it does now… Hmmm…

1 Like

Maybe it’s because I modified isDesktopOnly and it needs to be restarted to take effect? ​​I’m not sure.
I tried many times and can’t reproduce it yet.

Well, I had the PC turned off before, so…
No idea what’s happening.
Your plugin worked consistently then again, I couldn’t bring up the modal…?

I was going to say ignore the last post(s) from me but now I’d rather like some other people chip in with their own experiences.

Okay…so Text Finder must be enabled before the app is loaded…? So if one uses the Lazy Plugins loader, it must be added as Instant…?

Okay, so the modal works until I load a workspace. After that, I cannot invoke the modal.
Probably this is the problem I hit before but didn’t know how to reproduce it. I was able to reproduce it by loading different workspaces now.