how to shortcut the increase add space after and increase space before a paragraphi

Explorer ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

I want to use two shortcuts to improve my work.

I think it is possible by scripting but i don't know how so i ask here.
 i want to create a shortcut to increase space after paraprgaph as the button in palette and one to increase the space before the paragraph.

 

my left mouse button and relative finger will thank you forever.

TOPICS
How to, Scripting

Views

114

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Jun 03, 2021 Jun 03, 2021
For many years I have used small scripts to add or remove space before or after paragraphs. That's much easier than creating separate paragraph styles. Two scripts below: the first adds 1 pt to the space before the currently selected paragraph, the second one adds half a line of white before the current paragraph. 'Selected' means: just click somewhere in the paragraph. I use slight variants of these script to decrease the space by 1 point (simple change += with -=), and to add/remove space ...

Likes

Translate

Translate
Adobe Community Professional ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

I don't know anything about scripting but why don't you simply use paragraph styles?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

For many years I have used small scripts to add or remove space before or after paragraphs. That's much easier than creating separate paragraph styles.

 

Two scripts below: the first adds 1 pt to the space before the currently selected paragraph, the second one adds half a line of white before the current paragraph. 'Selected' means: just click somewhere in the paragraph.

 

I use slight variants of these script to decrease the space by 1 point (simple change += with -=), and to add/remove space after the selected paragraph (simply replace spaceBefore with spaceAfter).

 

Then assign these scripts to keyboard shortcuts. On my keyboard I use these keys:

F1: add 1 pt space before

Shift+F1: add half a line of white before

Ctrl+F1: remove 1 pt space before

F2: add 1 pt space after

Shift+F2: add half a line of white after

Ctrl+F2: remove 1 pt space after

 

These very simple scripts have saved me an enormous amount of time over the years.

 

P.

 

// Add 1 pt space before (to add e.g. 1 mm, use '1mm')

try {
  app.selection[0].spaceBefore += 1;
} catch (e) {
  alert (e.message);
}

 

// Add half a line of white before

function leading (p) {
  if (p.leading == Leading.AUTO) {
    return (app.selection[0].pointSize * p.autoLeading) / 100;
  }
  return p.leading;
}


try {
  par.spaceBefore += leading (par) / 2;
} catch (e) {
  alert (e.message);
}

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

LATEST

Mr Peter Kahrel, You are a lifesaver!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines