Is there a way to create a find and replace macro connected to a hotkey that will find and replace the same text string? As an example I want to remove "http://localhost" from all my documents before I upload to make the links site relative and this would be a fast way to make that conversion work.
When I try to record a macro, the macro stops recording when I try to execute a find and replace.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have also tried to do the same. I have several files in which I wanto to make a set of replacements, but they are not recorded in the macros.
Any idea?
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At present, the macro feature records only messages to the edit windows and (some, but not all) menu commands. It does not record any keystrokes or other messages to any of the N++ dialog boxes.
Sometimes you can work around this limitation by prepopulating the Find dialog with the search string, then close the dialog and record the macro using the <F3> (Find Next) and then <Del> and typing in the replace string (or pressing <Ctrl-V> to paste the clipboard contents). Those keystrokes will get recorded, but before playing the macro, you'll have to make sure the Find dialog is prepopulated (and, if necessary, copy the replace string to the clipboard).
Regards.
Greg
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If I was doing regular edits like that, I would use a batch process. I have used msub ( http://home.tiscali.dk/8x305617/provide/msub ) for this for years, but I'm sure there must be others around now.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay, let me get a "plug in" for my plugin (excuse the pun).
This is one of the reasons I created the SimpleScript plugin, because of limitations like this in the macros for Find-Replace operations. It's not exactly what you're looking for, but it's pretty close.
You can create a script that runs the replace, then once you've typed it in the Script window, you can use the hot key for "Repeat Last Script" (ALT-SHIFT-R by default, but you can change it through the Shortcut Mapper) as often as you need until you change the active script or close Notepad++.
In this case, the script would be just one line:
replace("http://localhost","")
If you use it all the time, you can add the script to the SimpleScript.ini file. Then you can just choose it off the list to make it the active script.
There are 2 drawbacks to using SimpleScript to do Find-Replace operations: First, you have to prepare it first by typing the script or selecting it off the list, but I've tried to make that as painless as possible. Second, it will only work on one file at a time, but once the script is loaded, you can keep opening files and running it on them with the hot key.
The nice thing is that you can string together a bunch of replaces, and there are a lot of other functions that you can work in as well if you need them.
The plugin is currently in beta because I'm fixing some bugs in the other functions, but I've tested the replace function extensively and it works perfectly as far as I can tell.
Hi, I'm brand new to Notepad++ and a non programmer. In this context, I hope it will be possible to articulate my problem in a way that makes sense.
I have a large text file and need to perform a large number of search and replace operations. The text file is replaced regularly, and so it is necessary to repeat the exercise (for my purposes) each time the updated file replaces the old.
I am able to record a macro to perform the replacements, and understand how to edit the .xml file using copy and paste to repeat the action for each string. The difficulty is that a dialogue box appears after each replace to tell me that 'x occurrences have been replaced'. As i will need to click 'OK' for some seventy-odd expressions, this will become tedious in short order.
I can find no way to record a click to the OK button so that the macro runs through all the substitutions I need without intervention. Ditto for the 'X' in the upper right of the box that closes the dialogue. I have recorded <esc>, but this does not work when appended to the end of each replace segment in the .xml file. Also, there is no underlined shortcut letter in the 'OK' button that I can use (I'm thinking Visual Basic now).
Any suggestions / solutions?
Alternatively, is there any way around this? For example, is it possible to perform multiple replace operations within a single search and replace execution?
Many thanks in advance, and apologies for the lengthy post.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am confused. Earlier in the thread it was said that you could not record a macro properly with search and replace functions. The last post said that a macro was recorded properly but that the "OK"s were not recorded. That was the case when I made my macro, it works OK but I have to click OK or hit enter for all the verification screens.
In my macro, that is not a big deal as it only has about 7 steps. I DO however have to be able to trust the macro working 100% of the time. I am using it to edit G code file for machine tools so that a program for one machine will run on another. These are expensive metal working machines which could crash and cause expensive damage if things aren't right.
I previously had a Word macro which did this and, after checking each file for some time, have been able to just run it and go. IT is wanting to cut the Word licenses used so I am looking to do this with freeware.
I have not read up on the .xml files which I am assuming are the macro files. I noticed that all the strings I used are in the "clipboard" of the search and replace screen. Will they go away and this not work eventually? Like if I use many other ones.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Earlier versions of N++ indeed would not recor find/replace in macros properly. In the meantime this has been fixed.
Suppressiong the Ok on each replace has been asked many times, t is addressed by another of my patches.
There is a maximum depth for retaining find/replace strings. You can set it manually in config.xml towards the end of the file - I think you'll find where easily. Hoever, you can't make some items sticky.
CChris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to create a find and replace macro connected to a hotkey that will find and replace the same text string? As an example I want to remove "http://localhost" from all my documents before I upload to make the links site relative and this would be a fast way to make that conversion work.
When I try to record a macro, the macro stops recording when I try to execute a find and replace.
Thanks.
I have also tried to do the same. I have several files in which I wanto to make a set of replacements, but they are not recorded in the macros.
Any idea?
Regards
Same here. The "save" is never lit when I do a find/replace. Even if I do it strictly by the keyboard.
At present, the macro feature records only messages to the edit windows and (some, but not all) menu commands. It does not record any keystrokes or other messages to any of the N++ dialog boxes.
Sometimes you can work around this limitation by prepopulating the Find dialog with the search string, then close the dialog and record the macro using the <F3> (Find Next) and then <Del> and typing in the replace string (or pressing <Ctrl-V> to paste the clipboard contents). Those keystrokes will get recorded, but before playing the macro, you'll have to make sure the Find dialog is prepopulated (and, if necessary, copy the replace string to the clipboard).
Regards.
Greg
If I was doing regular edits like that, I would use a batch process. I have used msub ( http://home.tiscali.dk/8x305617/provide/msub ) for this for years, but I'm sure there must be others around now.
Okay, let me get a "plug in" for my plugin (excuse the pun).
This is one of the reasons I created the SimpleScript plugin, because of limitations like this in the macros for Find-Replace operations. It's not exactly what you're looking for, but it's pretty close.
You can create a script that runs the replace, then once you've typed it in the Script window, you can use the hot key for "Repeat Last Script" (ALT-SHIFT-R by default, but you can change it through the Shortcut Mapper) as often as you need until you change the active script or close Notepad++.
In this case, the script would be just one line:
replace("http://localhost","")
If you use it all the time, you can add the script to the SimpleScript.ini file. Then you can just choose it off the list to make it the active script.
There are 2 drawbacks to using SimpleScript to do Find-Replace operations: First, you have to prepare it first by typing the script or selecting it off the list, but I've tried to make that as painless as possible. Second, it will only work on one file at a time, but once the script is loaded, you can keep opening files and running it on them with the hot key.
The nice thing is that you can string together a bunch of replaces, and there are a lot of other functions that you can work in as well if you need them.
The plugin is currently in beta because I'm fixing some bugs in the other functions, but I've tested the replace function extensively and it works perfectly as far as I can tell.
You can download SimpleScript here:
http://sourceforge.net/project/showfiles.php?group_id=189927&package_id=254135
Hi, I'm brand new to Notepad++ and a non programmer. In this context, I hope it will be possible to articulate my problem in a way that makes sense.
I have a large text file and need to perform a large number of search and replace operations. The text file is replaced regularly, and so it is necessary to repeat the exercise (for my purposes) each time the updated file replaces the old.
I am able to record a macro to perform the replacements, and understand how to edit the .xml file using copy and paste to repeat the action for each string. The difficulty is that a dialogue box appears after each replace to tell me that 'x occurrences have been replaced'. As i will need to click 'OK' for some seventy-odd expressions, this will become tedious in short order.
I can find no way to record a click to the OK button so that the macro runs through all the substitutions I need without intervention. Ditto for the 'X' in the upper right of the box that closes the dialogue. I have recorded <esc>, but this does not work when appended to the end of each replace segment in the .xml file. Also, there is no underlined shortcut letter in the 'OK' button that I can use (I'm thinking Visual Basic now).
Any suggestions / solutions?
Alternatively, is there any way around this? For example, is it possible to perform multiple replace operations within a single search and replace execution?
Many thanks in advance, and apologies for the lengthy post.
I am confused. Earlier in the thread it was said that you could not record a macro properly with search and replace functions. The last post said that a macro was recorded properly but that the "OK"s were not recorded. That was the case when I made my macro, it works OK but I have to click OK or hit enter for all the verification screens.
In my macro, that is not a big deal as it only has about 7 steps. I DO however have to be able to trust the macro working 100% of the time. I am using it to edit G code file for machine tools so that a program for one machine will run on another. These are expensive metal working machines which could crash and cause expensive damage if things aren't right.
I previously had a Word macro which did this and, after checking each file for some time, have been able to just run it and go. IT is wanting to cut the Word licenses used so I am looking to do this with freeware.
I have not read up on the .xml files which I am assuming are the macro files. I noticed that all the strings I used are in the "clipboard" of the search and replace screen. Will they go away and this not work eventually? Like if I use many other ones.
Earlier versions of N++ indeed would not recor find/replace in macros properly. In the meantime this has been fixed.
Suppressiong the Ok on each replace has been asked many times, t is addressed by another of my patches.
There is a maximum depth for retaining find/replace strings. You can set it manually in config.xml towards the end of the file - I think you'll find where easily. Hoever, you can't make some items sticky.
CChris