Qt Creator: Find and Replace using regular expressions
-
wrote on 2 Nov 2024, 17:56 last edited by Robert Hairgrove 11 Feb 2024, 17:59
After Qt Creator creates empty implementations for member functions declared in a header file, I would like to replace, for example:
ExceptionHandler::ExceptionHandler() { }
to result in this:
ExceptionHandler::ExceptionHandler() { // TO DO }
Unfortunately, I cannot find the correct regular expression to work which finds the
"{ }"
(with embedded newlines). I have tried"\{\n\n\}"
and"\{\n\n\}\n"
, for example, and have the option "Use regular expressions" checked.I also tried
"^\{\n\n\}$"
and"^\{\n\n\}\n$"
without success.Doubling the backslashes doesn't help, either.
Thanks for any help!
-
After Qt Creator creates empty implementations for member functions declared in a header file, I would like to replace, for example:
ExceptionHandler::ExceptionHandler() { }
to result in this:
ExceptionHandler::ExceptionHandler() { // TO DO }
Unfortunately, I cannot find the correct regular expression to work which finds the
"{ }"
(with embedded newlines). I have tried"\{\n\n\}"
and"\{\n\n\}\n"
, for example, and have the option "Use regular expressions" checked.I also tried
"^\{\n\n\}$"
and"^\{\n\n\}\n$"
without success.Doubling the backslashes doesn't help, either.
Thanks for any help!
wrote on 2 Nov 2024, 18:04 last edited by@Robert-Hairgrove
I think you will find Creator does not allow searching for newlines/multiline. It was requested but never implemented in 2010 :) Like many editors and tools it searches line by line. It can surprisingly insert newlines into the replacement, but not in the find string. -
@Robert-Hairgrove
I think you will find Creator does not allow searching for newlines/multiline. It was requested but never implemented in 2010 :) Like many editors and tools it searches line by line. It can surprisingly insert newlines into the replacement, but not in the find string.wrote on 2 Nov 2024, 19:13 last edited by@JonB Thanks! I wonder what other "features" of regex are broken here? Searching for newlines are really basic functionality. Geany, for example, does this perfectly ... it is also based on Scintilla, as is the editor in Qt Creator.
Maybe someone knows of a work-around?
-
@JonB Thanks! I wonder what other "features" of regex are broken here? Searching for newlines are really basic functionality. Geany, for example, does this perfectly ... it is also based on Scintilla, as is the editor in Qt Creator.
Maybe someone knows of a work-around?
wrote on 2 Nov 2024, 19:25 last edited by@Robert-Hairgrove said in Qt Creator: Find and Replace using regular expressions:
I wonder what other "features" of regex are broken here?
I'm not sure if this is related to regex.
Notepad++ for instance has different options for "normal" text search, regex and an option to convert and search backslash-n's, r's and so on...
So you can find every place where enter was pressed (like CR LF or\r\n
) very easily.But yeah, you are right... It should already be included in an IDE / TextEditor like QtCreator :(
-
wrote on 3 Nov 2024, 02:37 last edited by
Have added
Geany
as an external tool for this. -
1/5