Replace all marked words

  • Joakim Wadell

    Joakim Wadell - 2011-04-01

    Hi !

    I havn´t used notepad++ very much, but I like it.

    If I have the same word/number twice or more in a text, and marks that word/number it highlights all words/numbers of the context. If I want to replace all highlighted words/numbers, how do I do that ? I don´t wish to use replace (ctrl+h), it has to be a better way.

  • cchris

    cchris - 2011-04-02

    Could you describ the better way you are thinking of?


  • Joakim Wadell

    Joakim Wadell - 2011-04-03

    Like for an exemple:

    We have the same numbers in a text:

    "We have 1214 trucks in our garage, and we also have 1214 garage".

    I highlight the number 1214 and then I want to replace the number with a 1215, and want the change to effect every instance of the number 1214.

    So if I would change to "We have 1215 trucks in our garage", it would also change  "and we also have 1215 garage".

  • nofun

    nofun - 2011-04-03

    For now I know no better way than to point cursor at your number (for "Find what" field to be filled with your number on opening Replace dialog) and use keyboard shortcuts.

    There's another way of more limited use: when all the instances of your number are visible now, then you could also use multiple selections feature (must be turned on in Preferences): select one number with doubleclick, than select others by dragging the mouse with Ctrl pressed, than type your replacement string. It would be much more handy if Ctrl+doubleclick doesn't cancel previous selections, adding another ones instead, but it is impossible for now (you can vote for this feature request at IdeaTorrent.

    Maybe it is possible to combine smart highlighting and multiple selections into yet another approach: special 'replace highlights mode', enabled via keyboard shortcut or toolbar button, which converts all smart-highlighted terms into multiple selections, so that we'll only have to type a replacement string.

  • UrmasK

    UrmasK - 2013-04-30

    Late reply but I did register only for this topic.

    I agree that this option should be available. In different ways it's often important to replace specific items in the file (for example cleaning a log before sending it to analysis). So it would be great if you could:
    1. Ctrl+double click (for example) to select all similar items currently visible on the screen
    2. ctrl+v or del to replace/delete those visible selected items

  • Loreia2

    Loreia2 - 2013-04-30

    Hi UrmasK,

    you just need to add one step in the middle:
    1.b. Ctrl+H
    This brings Replace dialog, paste your replace term into dialog, and click "Replace All" (or hit Alt+A keyboard shortcut)

    I find this sufficient and easy enough.
    And you don't even need to select your keyword to be replaced, just have cursor in it when you press Ctrl+H.


  • sebastien

    sebastien - 2014-08-28

    No the correct sentence is "I find this sufficient enough in MY workflow over MY activities"

    There's many activities that could make great use of that feature : actually I did created an account as well JUST for that topic, and I found it because I'm browsing the net since half an hour now... having this feature would payback thoses 30mins lost without problem.

    I'm editing a lot of code, web related, and doing change about hex color, or parameters from CSS3 transformation which has to be declared for each vendors, etc...

    It's so frustrating to see neighbor instances getting highlighted but having to edit them one per one.... actually your control+H sounds good BUT it open a window that you will have to close, it goes thru whole document or into the selection : you might have to change this switch, etc... What coder needs is a shortcut and then type, enter to get out of multi edition, done, no more steps.

    Having just two shortcuts (one for 'neighbor instances', inside current block, as highlighting works, one for all over the document) would be sooooooooo faster for me.

    Actually a few editors are doing it, sublime text is an example of very good integration (2 shortcuts as I described). You can see users feelings about in opening topic like

    And honnestly, if I cannot find a way, plugin or whatever to achieve it within notepad++ I'll have to switch. Not trying to threaten, just a simple fact :(

    Last edit: sebastien 2014-08-28
  • Thomas

    Thomas - 2014-08-29

    Hi Sebastian,

    After having "Multi-Editing Setting" enabled (see the attached screen shot of the preference dialog) you can simply mark multiple words by double clicking while the CTRL key is pressed:

    In the attached screen shot with the text window I did this for the "abc" marked pink and the "abc" marked green (see marked-ABC.png be aware of the slightly color difference). When I type "xyz" all three marked instances of "abc" are replaced (see after-XYZ.png).


    Last edit: Thomas 2014-08-29