simsima
simsima

Reputation: 105

Intellij how to delete all line containing annotation?

I want to delete all lines that contains annotation. I see there is a shortcut to delete line/selection. But how do i pass regex to the delete line shortcut so that all line that starts with @ gets deleted? I want to use like this ^@

Upvotes: 7

Views: 4065

Answers (2)

Eternal Learner
Eternal Learner

Reputation: 116

Following @mahfuj-asif answer, you can update your regex like this \ \* @.*$|\/\*\*|\ \*\/, to remove all generated annotations, by using the same principle.

For example if you have a code like this:

    /**
     * @return int|null
     */
    public function getId(): ?int
    {
        return $this->id;
    }

And want to remove this part:

    /**
     * @return int|null
     */

Upvotes: 0

mahfuj asif
mahfuj asif

Reputation: 1979

You have to use replace option. Use Ctrl+R to open replace option, select regex(at the left side of search box there is a * sign). Enter @.*$ in replace box. Keep the replace with box empty.

The Regex means any line starting with @ followed by zero or more characters(digit/non digit/letter etc) and ended by end line.

enter image description here

Upvotes: 8

Related Questions