How can you find & delete lines? (not just replace with nothing)
Completed
- Using SHIFT+DEL allows me to delete an entire line.
- Find & Replace allows me to delete text on a line. (but the line remains)
I'm curious if there is a way to use functionality similar to find & replace to remove whole lines?
Please sign in to leave a comment.
Coffee hasn't kicked in. Regex.
Find:
Plus finding next line and replace all with next line.
Suppose there're two lines: "line1 \n line2", you can do as follows:
Marcel Wilson - doesnt that just add a new line?
Hey
What you can do is to find the text to delete and select all occurrences and the cursos will point on each line and just delete.
it worked for me
and after that delete
lol, as much as I like IntelliJ, this is where old school sed is easier...
Delete lines matching "JsonProperty' in every file under the current directory:
find . -type f |xargs sed -i '' -e '/JsonProperty/d'
And if anybody ends up here and wonders how this works for more complicated strings or even whole blocks:
Such a cool hidden feature :)
@Erick Jhorman Romero 's answer gave me the hint i needed, but to complete it, you can use the "delete line" shortcut after you clicked mark all.
On my setup that shortcut is CTRL+SHIFT+K
No regex, no matching whole line ;-)
NB.: I do love Regex, it's so powerful, but not when there is a simpler solution.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000142590/comments/115000185244
Adding to the previous answer, if regex gets complicated (needing to escape a bunch of chars)
2023.2.1 (Community Edition) contains a “New Line” button:
Note: The “Select All Occurences” answer is equally as effective as the find and replace with empty line.