• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Delete white space and line numbering

Enthusiast ,
Sep 26, 2022 Sep 26, 2022

Copy link to clipboard

Copied

Greetings to all

I want a script that removes the white space at the beginning of each line

Number each line at the beginning of each line

 

 

Sample.jpg

 

I attached a psd file to the text to illustrate the idea

TOPICS
Actions and scripting , SDK

Views

159

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

Guide , Sep 26, 2022 Sep 26, 2022

 

var s = activeDocument.activeLayer.textItem.contents.split('\r');
for (var i=0; i<s.length; i++) s[i] = s[i].replace(/^\s+/, i+1 + '/ ');
activeDocument.activeLayer.textItem.contents = s.join('\r');

 

Votes

Translate

Translate
Adobe
Guide ,
Sep 26, 2022 Sep 26, 2022

Copy link to clipboard

Copied

 

var s = activeDocument.activeLayer.textItem.contents.split('\r');
for (var i=0; i<s.length; i++) s[i] = s[i].replace(/^\s+/, i+1 + '/ ');
activeDocument.activeLayer.textItem.contents = s.join('\r');

 

Votes

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
Enthusiast ,
Sep 26, 2022 Sep 26, 2022

Copy link to clipboard

Copied

LATEST

@jazz-y 

Thank you very much for your interest and cooperation

Votes

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