Brief question for the ones who know ;)



  • It has been troubling my mind and I’d like to ask the following simple question for all Notepad++'s knowledgeable users out there. When you select a word in a program, in a, let’s say, python file, (doesn’t really matter anyway) and it shows you the other locations of the exact same word (by marking them as well) in your program, is there a combination of buttons that allows you to select all those same words and change them simultaneously? Or you have to suffer by changing them all (in the traditional way) one by one?
    Thanks for reading my text, if you know the answer please reply ;D



  • Search/Replace -> Replace All?



  • As @gerdb42 noted, Search/Replace -> Replace All seems to be what you are seeking.

    There’s one additional item to consider that search/replace works on strings of characters, not words. If you select the letter “a” Notepad++ will highlight the word “a” in the document and does not highlight appearances of the letter “a” that are part of words.

    Notepad++ considers consecutive letters, numeric digits, and underscores (_) to be “words.” All other characters are “not a word.”

    These are all “words” as far as Notepad++ is concerned. Double clicking on them will select/highlight the entire thing.

    • abc
    • 123
    • abc123
    • abc_123
    • _abc_123_

    Thus, if the intent is to search/replace a word then you should:

    • Double click on the word to select it.
    • Ctrl-H or if using the mouse then Search / Replace
    • The selected word is in the “find what” field.
    • Add (\W) before and after the word. For example, if you selected the word “of” then the “find what” field should look like (\W)of(\W) The parentheses mean ‘save or remember this’ and the \W (it has to be an upper case W, lower case will not work for this) matches any character that’s not part of a word [^a-z0-9_].
    • In the “replace with” box enter \1zzz\2 where zzz is the word or phrase you intend use in place of “of”. The \1 is the (\W) not-a-word-character that’s immediately before “of” and and the \2 is the (\W) not-a-word-character that’s immediately after the “of.”
    • Also, do you care about letter case? Is the intent to also change Of, oF, and OF or do you only want to change instances of all lower case “of?” If you enable the match-case checkbox then it will only match an all lower-case “of.”
    • Finally, the (\W) and \1\2 stuff is part of the regular expression language and so down in the lower-left corner of the search/replace box make sure that you are in regular expression mode.

    The short answer to your question is “yes.” :-)



  • Edit note: I’d first suggested using (\W)of(\W) replaced with \1zzz\2 but then realized that \b simplifies things. \W works like \b but also consumes the character in the search part meaning I needed to put them back in the replace part using \1\2. \b does not consume the character when searching and so does not been to be back back in the replace part. Here’s how to do it using \b

    • Double click on the word to select it.
    • Ctrl-H or if using the mouse then Search / Replace
    • Your selected word is in the “find what” field.
    • Add \b before and after the word. For example, if you selected the word “of” then the “find what” field should look like \bof\b The \b matches any character that’s not A-Z, 0-9, or _ and also matches the start of a line or end of a line.
    • In the “replace with” box whatever you want to replace “of” with.
    • Also, do you care about letter case? Is the intent to also change Of, oF, and OF or do you only want to change instances of all lower case “of?” If you enable the match-case checkbox then it will only match an all lower-case “of.”
    • Finally, the \b stuff is part of the regular expression language and so down in the lower-left corner of the search/replace box make sure that you are in regular expression mode.


  • Ok found it thanks a lot guys!



  • My first reaction when reading the OP’s question was that they want to have a way to create “n” selections based upon what is selected in a single selection. Then, typing will overwrite the contents of all “n” selections, in reality doing a visual, character-at-a-time replace.

    This posting (and corresponding Pythonscript by @Claudia-Frank ) does something similar and my be worth taking a look at: https://notepad-plus-plus.org/community/topic/11360/multi-selection-and-multi-edit


Log in to reply