Delete lines with PythonScript
Brian Higdon last edited by
I am using PythonScript and want to delete the whole line. Right now, I am using this:
editor.rereplace(r’^.: “”.$', ‘’)
and I am left with empty lines.
I can manually go to:
edit>line operations > remove empty lines.
but I do not see that option in the documentation PythonScript.
I have tried.
editor.replaceWholeLine (r’^.: “”.$', ‘’)
What setting or regex syntax do I need to include?
Any help would be grateful.
Alan Kilborn last edited by Alan Kilborn
@Brian-Higdon said in Delete lines with PythonScript:
I am using PythonScript and want to delete the whole line
lineis the line number you wish to delete.
If you want to do it with
rereplace, you need a correct pattern to match the line(s) to delete. I can’t tell from your posting what that is. But if you are “left with empty lines” then it probably means you didn’t include the line-ending in your pattern with
\Rand indeed I don’t see that in your pattern.
Maybe your “remove empty lines” comment is leading…about what you want to do… so let’s proceed with that:
You can execute that command in code with
With that as the basis of understanding, you could also do it with
Oh, wait…I think the empty lines only comes into it after you’ve done your
rereplaceand it didn’t do what you wanted.
I’m so confused… :-(
Brian Higdon last edited by Brian Higdon
@Alan-Kilborn Thank you for getting back to me so quickly.
Yes, you are correct on my regex string. Adding \R did what I needed it to do.
editor.rereplace(r’^.: “”.$\R’, ‘’)
You are not confused; I confusingly wrote my question.
The issue is solved.