Edit just one ocurrence in all files, not all ocurrences in all files.



  • Hello, i need help with something, is there any way to edit just one ocurrence in all the opened files instead of all the ocurrences in all files?



  • @D-A-G-13 said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    is there any way to edit just one ocurrence in all the opened files

    It is possible, however it might depend on the circumstances. If the first occurrence, it’s quite simple. If however it is possibly the nth occurrence it does become more difficult (not impossible).

    With a regex one can use a modifier to assert that the regex can cross line boundaries (?s). Thus the regex would look for the “word” (string of characters) and the remainder of the regex would also include the entire remaining portion of the file using (.*)

    Generally when a regex is made up it is customized entirely for the problem currently presented. So in order to advance your request for an asnwer you will have to elaborate some more, possibly presenting some examples, size of files (as this may have a bearing on whether it is even possible).

    Terry



  • I think i explained myself wrong, what i meant to say is that is possible to delete a blank space of just one line in every opened instead of all blank spaces in all opened files.

    Like, for example, the line 1 has a blank space and then a “{”, all the opened files have that space and the corchet in line 1, is there a way to delete that space of the line 1 in all the opened files?



  • @D-A-G-13 said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    the line 1 has a blank space and then a “{”,

    So is this “blank space” the first character on every file in line 1, or just somewhere on line 1. And as for the size of the file, if you could give us the potential size in number of characters (shows as length) which features on the bottom of the Notepad++ window and changes depending on which tab (file) is active.

    Terry



  • No, after the blank space is a “{”, and the length is 13142. what i’m looking is to delete the blank, what i’m looking for is that the “{” is sticking to the beginning of the text, removing the blank space, so for all open files.



  • This post is deleted!


  • @D-A-G-13 said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    removing the blank space, so for all open files.

    With some quick tests the following regex seems to work. As always it’s a good idea to have backups of files, and also randomly check the results afterwards. Use the length for a file and match it with the number after the replacement, the number should reduce by 1.
    So using the “Replace” function we have
    Find What:(?-s)(.*?)\x20(?s)(.*)
    Replace With:\1\2
    Make sure the search mode is regular expression and click on the “Replace All in All Opened Documents”.

    With my test of 4 files, 1 didn’t have any blank space in the first line and was left alone as expected.

    Terry

    PS had to remove last post as in fact it had affected the file with no space in first line. Altered regex to look specifically for the blank space (\x20)



  • @Terry-R said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    (?-s)(.?)\x20(?s)(.)

    Thanks man, it worked, sorry if i’m being greedy, but, can you make it place the “{” in just one click? If it’s not much the trouble.



  • @Terry-R said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    Find What:(?-s)(.?)\x20(?s)(.)

    I wish to revise that as a bit more thought revealed an issue. In fact the above regex will find the first occurrence of a blank space, regardless of which line it is. To anchor it to the first line I changed it to be
    Find What:(?-s)\A(.*?)\x20(?s)(.*)
    For the question in this thread the first regex would still perform correctly as OP stated there was a blank space in the first line of every file.
    Terry



  • @D-A-G-13 said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    but, can you make it place the “{”

    Can you provide an example. I don’t understand the question. Are you wanting to replace the blank space with the “{” or insert this somewhere (else)?

    Terry



  • For example, it anchors it of the beginning to the text, but i have to press the replace button several times for it, if you could make it to attach it in one click would be nice



  • @D-A-G-13 said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    but i have to press the replace button several times for it,

    Are you pressing the “Replace All in All Opened Documents” button. This WILL make a replacement in ALL OPENED files within Notepad++.

    Terry



  • Yes, but i moves just one space per click until it reaches the beginning of the file, i’m looking to make it reach the beginning in just one click.



  • @D-A-G-13 said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    is there any way to edit just one ocurrence in all the opened files instead of all the ocurrences in all files?

    This was your original question. You then followed that up with
    “is there a way to delete that space of the line 1 in all the opened files?”
    The solution removes the first occurrence of a blank space in all opened files if the blank space occurs on line 1.

    So if the solution does NOT meet your needs I think you need to explain more. Perhaps use some examples. Insert examples, then select them and click on the </> button immediately above the posting window. This will prevent the posting engine from changing any example text.
    At the moment I’m confused as to your request and the closest I can see is that you want the first occurrence on every line of a blank space to be replaced???

    Terry



  • @D-A-G-13 said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    but i moves just one space per click until it reaches the beginning of the file

    Oh hang on. Do you mean some of the files have more than 1 blank space together that you need to remove. If so then please use the 2nd regex (that has the \A in it) and change the \x20 to \x20+. This will select multiple blank spaces together and therefore removes them in 1 click.

    Terry



  • @Terry-R It worked perfectly, thanks a lot man, you’re my hero.



  • @D-A-G-13 said in Edit just one ocurrence in all files, not all ocurrences in all files.:

    It worked perfectly,

    I’m glad we got there eventually. It was hard work though.

    If you ask any further questions please do supply examples. If the data is sensitive (confidential) then alter the data but keep the structure as it originally was. It’s very important that examples as supplied for the very reason as shown in this thread. Presumably English isn’t your primary language as it seems you didn’t understand some of the questions well enough to give complete answers. That’s why examples are very important. Generally about 5 or so lines before and using the same example lines, repeat them showing the result you were expecting to get.

    Terry


Log in to reply