Updating a commonly used Dataview query in multiple notes

I have a Dataview query that I use in several dozen notes. The query is the same in every note that contains it, and generates a table. I use a Templater template to insert the query into new files.

I want to update the query from time to time – add columns to the table.

What is the most efficient way to globally change each instance of the query everywhere that it exists? I don’t want to have to search all notes looking for the query and replacing it.

1 Like

Unfortunately I think search and replace is the only way. You can shorten the task somewhat by using an external editor that can search and replace across multiple files at once (VS Code is often recommended, and I think BBEdit on Mac can do it). Of course, be careful and make sure your backups are up to date when modifying multiple files.

I strongly suggest switching out your existing query with a dv.view() call, and let the view function execute the query. This way when you want to change it later on, you’ll just update the view function, and that’s it.

I’m afraid using search and replace is your best option, and if would also give a vote for VS Code. It’s a very capable tool.

Then again, you could also do a search for something unique in your query from within Obsidian, and just have the new code in your clipboard, and then manually go through the search result, mark the entire section and hit paste (and thusly replace the entire section).

It’s tolerably efficient when you’re only talking about a one time operation in not too many files.

3 Likes

That might work out. I’ll try making the switch to dv.view(). (This suggestion was also helpful to me.)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.