Regex functionality for find and replace within obsidian

Regex functionality in find and replace inside Obsidian. Right now it’s still possible by opening the note in another editor like sublime text. But it’ll be great to have it in Obsidian itself.

91 Likes

Plugin maybe with Java regex support.

1 Like

Now that we have search please add replace as well. Also, having regex functionality in search for individual notes (CMD + F)

8 Likes

I’m especially missing a way to use new line as search/replace target/destination: \n does not works. Any other solutions (except the opening file in another editor)?

5 Likes

A few days ago I converted 600 .docx notes to markdown. Before I new the syntax --wrap=none in Pandoc, I put all of them in Vault and start process them. Notes are 80 characters line length as you can see in attached picture. Many of them have Title changed now and I can’t compare them anymore. So every time I have to copy/paste the text in Notepad++, run the regex syntax ^.+\K\R(?!\R) and replace results with a space in order to eliminate white spaces at the end of the line, but keep paragraph intact.

It would be nice to perform this task inside a note using Search & Replace with Regex.

Thanks!

5 Likes

The great thing about having local text files is that you can do such operations easily on the command line, e.g. using sed. But of course it would be even better if you could do this from inside Obsidian as well.

2 Likes

+1 I need this occasionally when I want to change the structure of a note. Right now I use a different editor for the function which isn’t ideal. This would be a nice feature.

1 Like

+1 I can’t believe there aren’t more requests for this!

2 Likes

Hopefully I’m not misunderstanding the ask here? As far as I can see (just tried it and it works) this can already be done inside a note using the vim search and replace functionality with the :s command:

2 Likes

+1 Maintaining the simplicity spirit of markdown, the potential interface in Obsidian for regex support doesn’t need to be prominent. Those who know regex are likely to “know” obsidian on a deeper level. It may be likely they will try regex queries in the search menu or find. Making this a “hidden” feature that just works in either of these places may be a win-win, while maintaining an un-bloated, clean interface.

2 Likes

This is not possible I fear. E.g. if an unaware user would search for e.g. they will find ergo and other things and wonder why this happens. That’s why in most search features searching for regexes must be explicitly activated/selected.

1 Like

It looks like VIM is the way to do this… still researching what it is and how to use it!

+1
this is a very important thing. very userfull for almost all users.
waiting for update.

2 Likes

I must admit I forgot that VIM mode is an option and isn’t just there for everyone! And of course it takes a little while to get your head around the modal nature of vim, but once you have it and have learn’t how to use it well it is a very efficient way to work.

1 Like

You can make this argument about any feature request. At that point, why even bother with new software after vim was created?

+1 regex in search and replace is crucial

8 Likes

While you’re not wrong, there’s definitely a case to be made for wise allocation of resources. On an infinite timescale, of course this is a feature that should be added. But is it something they should add today or tomorrow if folks can put in a little effort to figure out an alternative solution? Maybe.

I believe @Cito was merely (and wisely) pointing out that if this is a thing you need to do today, it’s already possible with a little legwork.

+1 for this feature. I have to supposedly move my vault into vs code to do find and replace on multiple files. I hope this get implemented inside obsidian soon.

I am having the same problem with pandoc. Is there any script that do that by any chance? it would be easy to place all the files in a folder and edit them in bulk using a loop

If the files are Word document, you can use this: Simple PowerShell (for now) script to convert Microsoft Word files into markdown with pandoc - #5 by mafsi

If you are on Windows and use notepad++ 32bit there is a plugin called TextFX that can unwrap you text, but you have to manually process all the files one by one

+1 this would be very useful