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, ifxxxxxxwas meant to mean “any text” rather than “six literalxcharacters”), 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
\uis 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
\uis 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\uas it also matches letters with diacritics.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login