Skip to main content
Participant
January 9, 2025
Question

Is there a keyboard shortcut/script to delete the current paragraph?

  • January 9, 2025
  • 5 replies
  • 580 views

Hi, I'm new here and have the following questions:

  1. Is there a keyboard shortcut/script to delete the current paragraph (where my cursor is)?
  2. Is there a keyboard shortcut/script to delete multiple selected paragraphs?
  3. If the above shortcuts don't exist, will Adobe consider adding them?

Any info will be appreciated. Thank you.

5 replies

Community Expert
January 9, 2025

Hi @Lewis_2688 ,

if you mean the scenario where you want to delete all paragraphs of your selection of text test the script code below.

Could be one single paragraph when you selected one insertion point or a couple of characters in one paragraph.

Could be a couple of paragraphs when your selection of characters exceeds the range of one paragraph at the same time.

 

The following script code is written in ExtendScript (JavaScript) :

try{ app.selection[0].paragraphs.everyItem().remove() }catch(e){};

You can attach a keyboard shortcut to every script file that is showing up in the Scripts panel of InDesign.

 

Regards,
Uwe Laubender
( Adobe Community Expert ) 

Anantha Prabu G
Legend
January 9, 2025

Hi @Lewis_2688 

var myDoc = app.activeDocument;
if (app.selection.length > 0) {
    var mySel = app.selection[0];
    if (mySel.hasOwnProperty("paragraphs")) {
        var myStory = mySel.parentStory;
        var myPara = mySel.paragraphs[0];
        myPara.remove();
    } else {
        alert("Please place the cursor inside a paragraph.");
    }
} else {
    alert("No text selected. Please select a text frame or place the cursor inside a paragraph.");
}
Design smarter, faster, and bolder with InDesign scripting.
Robert at ID-Tasker
Legend
January 9, 2025

@Anantha Prabu G

 

And from this, if you iterate BACKWARDS paragraphs collection and keep deleting LAST paragraph - it will be universal.

 

(ChatGPT generated?) 

 

Robert at ID-Tasker
Legend
January 9, 2025

@Lewis_2688

 

Yes, it's perfectly scriptable - unfortunately, I'm on my phone right now, but will try to do it later today.

 

Anantha Prabu G
Legend
January 9, 2025

Hi @Lewis_2688 
Deleting the Current Paragraph: Unfortunately, there isn't a default keyboard shortcut specifically for deleting the current paragraph where your cursor is. 

Design smarter, faster, and bolder with InDesign scripting.
leo.r
Community Expert
Community Expert
January 9, 2025

1. I assume you know you can quadruple-click to select a paragraph? 

2. I assume that you refer to multiple partially selected paragraphs? Because otherwise the answer is, obviously, to just use the delete key.

 

In any case, both operations are also possible, in theory, to perform with scripts without having to select the paragraph(s) manually.