How can I delete lines that contain a specific text

Post Reply
BBServ
Posts: 15
Joined: 01.04.2021 17:20

How can I delete lines that contain a specific text

Post by BBServ »

I have been using CudaText for a few months now and have been able to find ways to easily do most of the things I do on a regular basis. The one thing that I have not been able to do with the ease and speed of my previous editor is to delete lines containing a specific text. I can get that accomplished by finding the string and selecting all occurrences, bookmarking the carets, and then deleting lines with the bookmarks. I tried a macro, but it keeps the previously used string as indicated below "gallbladder":

Code: Select all

ed.cmd(cmds.cmd_FinderAction,'findsel\x01[color=#4000FF][color=#FF4040]gallbladder[/color][/color]\x01\x01')
ed.cmd(cmds.cmd_BookmarkPlaceBookmarksOnCarets)
ed.cmd(cmds.cmd_BookmarkDeleteMarkedLines)
I thought this would be ideal for a plugin, but I found quickly that is above my level of expertise.

Is there a plugin that has this functionality or a way I can change the macro to have it prompt me for the string?

Thanks in advance for any help.

joe
main Alexey
Posts: 2708
Joined: 25.08.2021 18:15

Post by main Alexey »

I wrote a small plugin. it gives 2 commands:

Plugins / Select lines with text / Select lines...
Plugins / Select lines with text / Delete lines...

They ask for a string.
Please test.
Open zip file in CudaText and confirm to install.
When it's OK I may merge it to CudaExt plugin.
Attachments
cuda_sel_lines_with_text.zip
(636 Bytes) Downloaded 130 times
BBServ
Posts: 15
Joined: 01.04.2021 17:20

Post by BBServ »

Thank you! The plugin works well. I appreciate your kindness.
main Alexey
Posts: 2708
Joined: 25.08.2021 18:15

Post by main Alexey »

Plugin CudaExt updated.
1.7.36 (2022-01-05)
added: Command "Delete lines containing text..." (by Alexey T.)
Post Reply