Macro command
-
Hello. I have a word of the form ”xxxxxx” and I want to change it to the word „xxxxxx”, what is the command for a macro in notepad++? I would like to have a command that can change all words of this type in all open documents. Plaese help me, thanks.
-
To do a search/replace, use Search > Replace (
Ctrl+H
). If you want to use wildcards (that is, ifxxxxxx
was meant to mean “any text” rather than “six literalx
characters”), then you would use Regular Expression mode: so- Find What:
"(.*)"
- Replace With:
„$1”
- Search Mode: Regular Expression
- Replace All
If you were going to be doing that same replacement frequently, for days or weeks or months to come, then you could use the macro feature: Macro > Start Recording, do that replacement once so it gets recorded, Macro > Stop Recording then Save Current Recorded Macro and give it a name (and maybe a shortcut) – then the Macro menu (and the shortcut) would have your search/replace saved so you could use it from the menu (or a keyboard shortcut).
I would like to have a command that can change all words of this type in all open documents.
update: I didn’t notice this during my initial reply. For that, I would recommend not using the Macro, and just using the Replace dialog. And instead of hitting Replace All, you would use Replace All in All Open Documents.
----
Useful References
- Find What:
-
In this case, since @Paunescu-Marius didn’t post with proper formatting, we are not sure if his starting point is “curly” double quotes, or “traditional” quotes.
-
One of the things that is not clear from @Paunescu-Marius’ post is if there are ever orphan quotes, two or more quoted words or phrases on a line, quoted things that span two or more lines, etc.
It may be safer to use:
** Search:"(\u+)"
Replace:„$1”
It’s the same as what @PeterJones suggested but uses
\u+
instead of.*
. However, it will only match and fix single words enclosed in quotes such as"this"
and will not match a series of two or more words separated by spaces, that contain punctuation, etc.Doing a search/replace on all open documents is always a deadly game and so it’s best to make a backup of the data before attempting clean it and as conservative as possible when constructing the search or match part of a regular expression.
-
@mkupper ,
Good point. And my
".*"
is probably too greedy, so".*?"
would be better.But until @Paunescu-Marius gives more detail, making too many more guesses is probably pretty inefficient for us (and likely to still not hit the mark for the hidden details)
-
@mkupper said:
Search: “(\u+)”
I’m not confident that
\u
is the “best” thing to use here…and also it fails miserably if Match case is inadvertently checkmarked… -
@Alan-Kilborn said in Macro command:
@mkupper said:
Search: “(\u+)”
I’m not confident that
\u
is the “best” thing to use here…and also it fails miserably if Match case is inadvertently checkmarked…You are right. It should have been a search for
(?i)"(\u+)"
and I even have the(?i)
part in my own notes about using\u
. I had noticed that English is likely not the OP’s first language which is why I thought of\u
as it also matches letters with diacritics.