Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace All #545

Open
ben-albon opened this issue Dec 30, 2020 · 3 comments
Open

Replace All #545

ben-albon opened this issue Dec 30, 2020 · 3 comments
Assignees
Labels
editor Component: Editor enhancement Request: New feature or improvement

Comments

@ben-albon
Copy link

As a discovery writer, I want to be able to quickly and efficiently change the name of characters in my early drafts (for example, from John Smith, to James Doe).

The existing search and replace tools (match whole worlds, preserve case, etc.) are impressively powerful, but I would like the option of being able to replace all occurances within a document.

@ben-albon ben-albon added the enhancement Request: New feature or improvement label Dec 30, 2020
@vkbo
Copy link
Owner

vkbo commented Dec 30, 2020

The search and replace tool set are all features that are available in the underlying Qt library. There is no "find all" functionality, and the search feature itself is iterative. I can of course implement a "replace all" as a loop that just repeats the search/replace until the end, but I've avoided this so far because there's no practical way to preview the changes beforehand. The safest way to achieve this is to hit the replace keyboard shortcut multiple times to iterate through the document and inspect each replace first.

So, essentially, the reason why this isn't implemented is that it may cause the user to make mistakes that can be tricky to revert. However, many other editors do this and leave it to the user to take that risk, so I am not strongly opposed to adding it. I'll look into it anyway.

@vkbo vkbo self-assigned this Dec 30, 2020
@vkbo vkbo added this to the Release 1.1 RC 1 milestone Jan 15, 2021
@vkbo vkbo removed this from the Release 1.1 RC 1 milestone Jan 24, 2021
@4z0r
Copy link

4z0r commented Jan 3, 2022

This would be a neat feature for minor characters, places and entities. Even if I'm not a 'discovery' writer.

On my part however, using Linux, I managed without by securing the entire folder beforehand, finding all files with all the matching words and running sed on each file. Brutal I know, but it was for a minor character and I'm not that far into the novel. Plus it worked like a charm.

Late changes would be nice though via the novelWriter, even without an actual preview on the changes. Wouldn't be much better than my early approach, but I'd personally trust the available search and replace in a loop over all pages way more over a hacky fgrep + sed after a long night of writing.

@vkbo
Copy link
Owner

vkbo commented Jan 3, 2022

In the upcoming release I've improved the search/replace tool to at least show the number of occurrences in the current document. It makes it a little easier to see upfront what's going on.

Feature #894 asks for a global search feature, which can fairly easily be extended to a global replace feature. I'm still not thrilled about the potential risk of an ill formatted search messing up someone's project, so some form of preview of the results are needed. It's not a trivial tool to write though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Component: Editor enhancement Request: New feature or improvement
Projects
None yet
Development

No branches or pull requests

3 participants