TeXShop: a way to automate terminating each line in a block with a comment symbol

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

TeXShop: a way to automate terminating each line in a block with a comment symbol

Murray Eisenberg
I have long blocks of code within a \newcommand{\cmdname}{…} definition that need to have each of the lines terminated with a comment sign (%).

Is there some way to select the block and apply that automatically?

Some trick I’ve missed? some macro I’ve overlooked?

---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334


----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Luis Sequeira-5
> I have long blocks of code within a \newcommand{\cmdname}{?} definition that need to have each of the lines terminated with a comment sign (%).
>
> Is there some way to select the block and apply that automatically?
>
> Some trick I?ve missed? some macro I?ve overlooked?


That is very easy to do.


1) Select the block of text where you want to add the comment sign.

2) Press Command-F to open the Find window

3) Chech the box for "Regular Expressions"
   Make sure that you have selected Origin: "Top" and Scope: "Selection"

   Type "$" (without quotes) in the search box
   Type "%" (without quotes) in the replace box
   Press Replace All


Done.


Regards

LS

----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Ross Moore-3
In reply to this post by Murray Eisenberg
Hello Murray,

On 17 May 2020, at 2:40 am, Murray Eisenberg <[hidden email]> wrote:

I have long blocks of code within a \newcommand{\cmdname}{…} definition that need to have each of the lines terminated with a comment sign (%).

Is there some way to select the block and apply that automatically?

Some trick I’ve missed? some macro I’ve overlooked?

My favourite motto is:
    “there’s always more than one way to do … “

Using a macro in the editor is one way, as Luis describes.

But you can get what you want entirely within TeX coding, 
without adding any comment characters.

Just surround your definition block as follows.

\endlinechar=-1  %  suppress line endings from this point 

\newcommand{\mylongmacro}{…  
 …
 … }

\endlinechar=13    %  On a Mac the end-of-line character is  Ux0D  = ASCII 13 


This kind of thing is normally done within package  .sty  files.
If you want to check the status of  \endlinechar  at any point, for whatever reason,
just use:

 \showthe\endlinechar



Hope this helps.
Stay safe.

Ross


---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334


----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex



----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Murray Eisenberg
In reply to this post by Luis Sequeira-5
It’s worth saying three things for this procedure:

(a) This method is possible only when using the OgreKit Find Panel.

(b) It does not work as I’d expect if there are trailing blanks in one of the block’s lines, as it leaves those unwanted blanks there.

(c) [of course] one also has to check the “Selection” option of the Scope section in the OgreKit Find Panel.

** It would still be very nice to have a TeXShop menu items, or at least a macro, to do this operation.

Compare, for example, BBEdit, where after selecting a block of lines, one uses the Text > Prefix/Suffix Lines menu item and then just enters the desired prefix or suffix in the resulting pop-up window.  (Albeit that suffers from the same trailing-blank issue.) I suspect other programmers’ text editors have similar built-in menu items or macros.

On 17 May2020, at 6:37 AM, Luis Sequeira <[hidden email]> wrote:

1) Select the block of text where you want to add the comment sign.

2) Press Command-F to open the Find window

3) Chech the box for "Regular Expressions"
  Make sure that you have selected Origin: "Top" and Scope: "Selection"

  Type "$" (without quotes) in the search box
  Type "%" (without quotes) in the replace box
  Press Replace All

---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334



----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Herbert Schulz
> On May 17, 2020, at 2:36 PM, Murray Eisenberg <[hidden email]> wrote:
>
> It’s worth saying three things for this procedure:
>
> (a) This method is possible only when using the OgreKit Find Panel.
>
> (b) It does not work as I’d expect if there are trailing blanks in one of the block’s lines, as it leaves those unwanted blanks there.
>
> (c) [of course] one also has to check the “Selection” option of the Scope section in the OgreKit Find Panel.
>
> ** It would still be very nice to have a TeXShop menu items, or at least a macro, to do this operation.
>
> Compare, for example, BBEdit, where after selecting a block of lines, one uses the Text > Prefix/Suffix Lines menu item and then just enters the desired prefix or suffix in the resulting pop-up window.  (Albeit that suffers from the same trailing-blank issue.) I suspect other programmers’ text editors have similar built-in menu items or macros.
>
>> On 17 May2020, at 6:37 AM, Luis Sequeira <[hidden email]> wrote:
>>
>> 1) Select the block of text where you want to add the comment sign.
>>
>> 2) Press Command-F to open the Find window
>>
>> 3) Chech the box for "Regular Expressions"
>>   Make sure that you have selected Origin: "Top" and Scope: "Selection"
>>
>>   Type "$" (without quotes) in the search box
>>   Type "%" (without quotes) in the replace box
>>   Press Replace All
>

Howdy,

How I wish the Ogrekit find panel was fixed for Catalina, especially to get it to work properly in Dark Mode.

Take a look at the Cot Editor (available for free via the App Store). It has a beautiful regex ready Find Panel that works beautifully in Dark Mode. It would be wonderful is someone could get that to work in TeXShop. PS: the Cot Editor is Open Software written in Swift with freely available source code.

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)

----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Murray Eisenberg
On 17 May2020, at 3:53 PM, Herbert Schulz <[hidden email]> wrote:

On May 17, 2020, at 2:36 PM, Murray Eisenberg <[hidden email]> wrote:

It’s worth saying three things for this procedure:

(a) This method is possible only when using the OgreKit Find Panel.

(b) It does not work as I’d expect if there are trailing blanks in one of the block’s lines, as it leaves those unwanted blanks there.

(c) [of course] one also has to check the “Selection” option of the Scope section in the OgreKit Find Panel.

** It would still be very nice to have a TeXShop menu items, or at least a macro, to do this operation.

Compare, for example, BBEdit, where after selecting a block of lines, one uses the Text > Prefix/Suffix Lines menu item and then just enters the desired prefix or suffix in the resulting pop-up window.  (Albeit that suffers from the same trailing-blank issue.) I suspect other programmers’ text editors have similar built-in menu items or macros.

On 17 May2020, at 6:37 AM, Luis Sequeira <[hidden email]> wrote:

1) Select the block of text where you want to add the comment sign.

2) Press Command-F to open the Find window

3) Chech the box for "Regular Expressions"
 Make sure that you have selected Origin: "Top" and Scope: "Selection"

 Type "$" (without quotes) in the search box
 Type "%" (without quotes) in the replace box
 Press Replace All


Howdy,

How I wish the Ogrekit find panel was fixed for Catalina, especially to get it to work properly in Dark Mode.

Take a look at the Cot Editor (available for free via the App Store). It has a beautiful regex ready Find Panel that works beautifully in Dark Mode. It would be wonderful is someone could get that to work in TeXShop. PS: the Cot Editor is Open Software written in Swift with freely available source code.


Using the specified regexs in the OgreKit panel worked just fine.

Unfortunately, I never really learned regexs, so in any task requiring one I need explicit instructions on exactly what to do.

In TeXShop we already have a really easy-to-use menu item, plus associated keystroke shortcut, to comment a selected block of lines.
Given that defining multi-line commands is hardly unknown to TeXers, even non-experts like me, a corresponding menu command/shortcut to comment end of lines would be genuine convenience.
---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334



----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

MacOSX-TeX mailing list
Hi Murray,

My feed from this list is no longer reliable as I seem not to receive a number of messages that are referenced by later emails, so I'm not entirely sure that I'm understanding what it is you need. Nonetheless, here is a macro that solves what I think is the problem you are asking about. When you select text is the frontmost document and call this macro, it replaces all <whitespace}+<endofline> with "%"<endofline>.

The plist should be installed into the Macros Menu just like any other such plist, as documented in the TeXShop docs.

Best,
Michael



On May 17, 2020, at 5:33 PM, Murray Eisenberg <[hidden email]> wrote:

On 17 May2020, at 3:53 PM, Herbert Schulz <[hidden email]> wrote:

On May 17, 2020, at 2:36 PM, Murray Eisenberg <[hidden email]> wrote:

It’s worth saying three things for this procedure:

(a) This method is possible only when using the OgreKit Find Panel.

(b) It does not work as I’d expect if there are trailing blanks in one of the block’s lines, as it leaves those unwanted blanks there.

(c) [of course] one also has to check the “Selection” option of the Scope section in the OgreKit Find Panel.

** It would still be very nice to have a TeXShop menu items, or at least a macro, to do this operation.

Compare, for example, BBEdit, where after selecting a block of lines, one uses the Text > Prefix/Suffix Lines menu item and then just enters the desired prefix or suffix in the resulting pop-up window.  (Albeit that suffers from the same trailing-blank issue.) I suspect other programmers’ text editors have similar built-in menu items or macros.

On 17 May2020, at 6:37 AM, Luis Sequeira <[hidden email]> wrote:

1) Select the block of text where you want to add the comment sign.

2) Press Command-F to open the Find window

3) Chech the box for "Regular Expressions"
 Make sure that you have selected Origin: "Top" and Scope: "Selection"

 Type "$" (without quotes) in the search box
 Type "%" (without quotes) in the replace box
 Press Replace All


Howdy,

How I wish the Ogrekit find panel was fixed for Catalina, especially to get it to work properly in Dark Mode.

Take a look at the Cot Editor (available for free via the App Store). It has a beautiful regex ready Find Panel that works beautifully in Dark Mode. It would be wonderful is someone could get that to work in TeXShop. PS: the Cot Editor is Open Software written in Swift with freely available source code.


Using the specified regexs in the OgreKit panel worked just fine.

Unfortunately, I never really learned regexs, so in any task requiring one I need explicit instructions on exactly what to do.

In TeXShop we already have a really easy-to-use menu item, plus associated keystroke shortcut, to comment a selected block of lines.
Given that defining multi-line commands is hardly unknown to TeXers, even non-experts like me, a corresponding menu command/shortcut to comment end of lines would be genuine convenience.
---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334


----------- Please Consult the Following Before Posting -----------
TeX FAQ: https://urldefense.com/v3/__http://www.tex.ac.uk/faq__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ89r7SRf0$
List Reminders and Etiquette: https://urldefense.com/v3/__https://sites.esm.psu.edu/*gray/tex/__;fg!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ8QrtzZfE$
List Archives: https://urldefense.com/v3/__http://dir.gmane.org/gmane.comp.tex.macosx__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ83gNi63c$
               https://urldefense.com/v3/__https://email.esm.psu.edu/pipermail/macosx-tex/__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ8oFDMyFs$
TeX on Mac OS X Website: https://urldefense.com/v3/__http://mactex-wiki.tug.org/__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ8zot6LfE$
List Info: https://urldefense.com/v3/__https://email.esm.psu.edu/mailman/listinfo/macosx-tex__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ8Zax5i6w$


----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex

commentEnds.plist (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Murray Eisenberg
Michael,

Thanks for this attempt. It does, though have two issues:

(1) It does NOT remove trailing spaces between the last ordinary character on a line and the end of the line;

(2) for each and every line in the block affected, it causes a little pop-up window showing the line, and one has to dismiss that pop-up window before it then automatically goes to the next line to process.

Below is the sample text on which I tried it. I selected the block of lines from the third to the next-to-last there and called the macro.

\definecolor{magenta}{rgb}{1.0, 0.0, 1.0}
\definecolor{tangerine}{rgb}{0.95, 0.52, 0.0}
\definecolor{ufogreen}{rgb}{0.24, 0.82, 0.44}
\definecolor{platinum}{rgb}{0.9, 0.89, 0.89}
\definecolor{amber}{rgb}{1.0, 0.75, 0.0}
\definecolor{atomictangerine}{rgb}{1.0, 0.6, 0.4}
\definecolor{cyan}{rgb}{0.0, 1.0, 1.0}
\definecolor{lightcyan}{rgb}{0.88, 1.0, 1.0}
\definecolor{lavendermagenta}{rgb}{0.93, 0.51, 0.93}
\definecolor{lavenderrose}{rgb}{0.98, 0.63, 0.89}
\definecolor{MiddleBlue}{rgb}{0.67, 0.9, 0.93}
\definecolor{cream}{rgb}{1.0, 0.99, 0.82}
\definecolor{brightgreen}{rgb}{0.4, 1.0, 0.0}
\definecolor{lime(colorwheel)}{rgb}{0.75, 1.0, 0.0}
\definecolor{lime(web)(x11green)}{rgb}{0.0, 1.0, 0.0}
\definecolor{mediumspringgreen}{rgb}{0.0, 0.98, 0.6}
\definecolor{mintgreen}{rgb}{0.6, 1.0, 0.6}
\definecolor{neongreen}{rgb}{0.22, 0.88, 0.08}
  

On 18 May2020, at 12:58 AM, Michael Sharpe via MacOSX-TeX <[hidden email]> wrote:

Hi Murray,

My feed from this list is no longer reliable as I seem not to receive a number of messages that are referenced by later emails, so I'm not entirely sure that I'm understanding what it is you need. Nonetheless, here is a macro that solves what I think is the problem you are asking about. When you select text is the frontmost document and call this macro, it replaces all <whitespace}+<endofline> with "%"<endofline>.

The plist should be installed into the Macros Menu just like any other such plist, as documented in the TeXShop docs.

Best,
Michael

<commentEnds.plist>

On May 17, 2020, at 5:33 PM, Murray Eisenberg <[hidden email]> wrote:

On 17 May2020, at 3:53 PM, Herbert Schulz <[hidden email]> wrote:

On May 17, 2020, at 2:36 PM, Murray Eisenberg <[hidden email]> wrote:

It’s worth saying three things for this procedure:

(a) This method is possible only when using the OgreKit Find Panel.

(b) It does not work as I’d expect if there are trailing blanks in one of the block’s lines, as it leaves those unwanted blanks there.

(c) [of course] one also has to check the “Selection” option of the Scope section in the OgreKit Find Panel.

** It would still be very nice to have a TeXShop menu items, or at least a macro, to do this operation.

Compare, for example, BBEdit, where after selecting a block of lines, one uses the Text > Prefix/Suffix Lines menu item and then just enters the desired prefix or suffix in the resulting pop-up window.  (Albeit that suffers from the same trailing-blank issue.) I suspect other programmers’ text editors have similar built-in menu items or macros.

On 17 May2020, at 6:37 AM, Luis Sequeira <[hidden email]> wrote:

1) Select the block of text where you want to add the comment sign.

2) Press Command-F to open the Find window

3) Chech the box for "Regular Expressions"
 Make sure that you have selected Origin: "Top" and Scope: "Selection"

 Type "$" (without quotes) in the search box
 Type "%" (without quotes) in the replace box
 Press Replace All


Howdy,

How I wish the Ogrekit find panel was fixed for Catalina, especially to get it to work properly in Dark Mode.

Take a look at the Cot Editor (available for free via the App Store). It has a beautiful regex ready Find Panel that works beautifully in Dark Mode. It would be wonderful is someone could get that to work in TeXShop. PS: the Cot Editor is Open Software written in Swift with freely available source code.


Using the specified regexs in the OgreKit panel worked just fine.

Unfortunately, I never really learned regexs, so in any task requiring one I need explicit instructions on exactly what to do.

In TeXShop we already have a really easy-to-use menu item, plus associated keystroke shortcut, to comment a selected block of lines.
Given that defining multi-line commands is hardly unknown to TeXers, even non-experts like me, a corresponding menu command/shortcut to comment end of lines would be genuine convenience.
---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334


----------- Please Consult the Following Before Posting -----------
TeX FAQ: https://urldefense.com/v3/__http://www.tex.ac.uk/faq__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ89r7SRf0$
List Reminders and Etiquette: https://urldefense.com/v3/__https://sites.esm.psu.edu/*gray/tex/__;fg!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ8QrtzZfE$
List Archives: https://urldefense.com/v3/__http://dir.gmane.org/gmane.comp.tex.macosx__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ83gNi63c$
               https://urldefense.com/v3/__https://email.esm.psu.edu/pipermail/macosx-tex/__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ8oFDMyFs$
TeX on Mac OS X Website: https://urldefense.com/v3/__http://mactex-wiki.tug.org/__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ8zot6LfE$
List Info: https://urldefense.com/v3/__https://email.esm.psu.edu/mailman/listinfo/macosx-tex__;!!Mih3wA!TmYjcfVgC7XceqlH--ECBZew63EkibBgVRR-Wcusjpw2Qp7Gb2b66dZ8Zax5i6w$

----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
               https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex

---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334



----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Martin Costabel
In reply to this post by Murray Eisenberg
In Luis Sequeira's method you can easily remove trailing blanks. Just write
" *$" (without quotes) instead of "$" (without quotes) in the search box.

--
Martin

On 17/05/20 21:36, Murray Eisenberg wrote:

> It’s worth saying three things for this procedure:
>
> (a) This method is possible only when using the OgreKit Find Panel.
>
> (b) It does not work as I’d expect if there are trailing blanks in one
> of the block’s lines, as it leaves those unwanted blanks there.
>
> (c) [of course] one also has to check the “Selection” option of the
> Scope section in the OgreKit Find Panel.
>
> ** It would still be very nice to have a TeXShop menu items, or at least
> a macro, to do this operation.
>
> Compare, for example, BBEdit, where after selecting a block of lines,
> one uses the Text > Prefix/Suffix Lines menu item and then just enters
> the desired prefix or suffix in the resulting pop-up window.  (Albeit
> that suffers from the same trailing-blank issue.) I suspect other
> programmers’ text editors have similar built-in menu items or macros.
>
>> On 17 May2020, at 6:37 AM, Luis Sequeira <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>> 1) Select the block of text where you want to add the comment sign.
>>
>> 2) Press Command-F to open the Find window
>>
>> 3) Chech the box for "Regular Expressions"
>>   Make sure that you have selected Origin: "Top" and Scope: "Selection"
>>
>>   Type "$" (without quotes) in the search box
>>   Type "%" (without quotes) in the replace box
>>   Press Replace All
>
> ---
----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Murray Eisenberg
Perfect! thank you.

> On 18 May2020, at 2:58 PM, Martin Costabel <[hidden email]> wrote:
>
> In Luis Sequeira's method you can easily remove trailing blanks. Just write
> " *$" (without quotes) instead of "$" (without quotes) in the search box.
>
> --
> Martin
>
> On 17/05/20 21:36, Murray Eisenberg wrote:
>> It’s worth saying three things for this procedure:
>>
>> (a) This method is possible only when using the OgreKit Find Panel.
>>
>> (b) It does not work as I’d expect if there are trailing blanks in one
>> of the block’s lines, as it leaves those unwanted blanks there.
>>
>> (c) [of course] one also has to check the “Selection” option of the
>> Scope section in the OgreKit Find Panel.
>>
>> ** It would still be very nice to have a TeXShop menu items, or at least
>> a macro, to do this operation.
>>
>> Compare, for example, BBEdit, where after selecting a block of lines,
>> one uses the Text > Prefix/Suffix Lines menu item and then just enters
>> the desired prefix or suffix in the resulting pop-up window.  (Albeit
>> that suffers from the same trailing-blank issue.) I suspect other
>> programmers’ text editors have similar built-in menu items or macros.
>>
>>> On 17 May2020, at 6:37 AM, Luis Sequeira <[hidden email]
>>> <mailto:[hidden email]>> wrote:
>>>
>>> 1) Select the block of text where you want to add the comment sign.
>>>
>>> 2) Press Command-F to open the Find window
>>>
>>> 3) Chech the box for "Regular Expressions"
>>>   Make sure that you have selected Origin: "Top" and Scope: "Selection"
>>>
>>>   Type "$" (without quotes) in the search box
>>>   Type "%" (without quotes) in the replace box
>>>   Press Replace All
>>
>> ---

---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334


----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Luis Sequeira-5
In reply to this post by Murray Eisenberg
Murray, a few comments on your comments:

        (a) This method is possible only when using the OgreKit Find Panel.

True. I have always used OgreKit. I do remember there were other options, but OgreKit is so much more flexible.


        (b) It does not work as I?d expect if there are trailing blanks in one of the block?s lines, as it leaves those unwanted blanks there.

This one is very easy.
Just replace the find regular expression to include any number of blanks before the end of the line.

Instead of "$", search for "\b*$"

Incidentally, regular expressions are not that hard to figure out.
I use them a lot, both in TeXShop and BBEdit (and good'ole vi...)

        (c) [of course] one also has to check the ?Selection? option of the Scope section in the OgreKit Find Panel.

I did write that!



Also: yes, it would be nice to have a macro for it, and I have no doubt one can be created, but I have not looked much into it.

Regards

LS
----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Murray Eisenberg
Is the regex search for  "\b*$” equivalent to what Martin Costabel suggested, to use " *$” ??

> On 18 May2020, at 4:38 PM, Luis Sequeira <[hidden email]> wrote:
>
> Murray, a few comments on your comments:
>
> (a) This method is possible only when using the OgreKit Find Panel.
>
> True. I have always used OgreKit. I do remember there were other options, but OgreKit is so much more flexible.
>
>
> (b) It does not work as I?d expect if there are trailing blanks in one of the block?s lines, as it leaves those unwanted blanks there.
>
> This one is very easy.
> Just replace the find regular expression to include any number of blanks before the end of the line.
>
> Instead of "$", search for "\b*$"
>
> Incidentally, regular expressions are not that hard to figure out.
> I use them a lot, both in TeXShop and BBEdit (and good'ole vi...)
>
> (c) [of course] one also has to check the ?Selection? option of the Scope section in the OgreKit Find Panel.
>
> I did write that!
>
>
>
> Also: yes, it would be nice to have a macro for it, and I have no doubt one can be created, but I have not looked much into it.
>
> Regards
>
> LS
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
> List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
>                https://email.esm.psu.edu/pipermail/macosx-tex/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex

---
Murray Eisenberg [hidden email]
503 King Farm Blvd #101 Home (240)-246-7240
Rockville, MD 20850-6667 Mobile (413)-427-5334


----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
Reply | Threaded
Open this post in threaded view
|

Re: TeXShop: a way to automate terminating each line in a block with a comment symbol

Nicolas Martignoni-3
No, this will find any number of white spaces (including tabs) at end of line.

--
Nicolas Martignoni
[hidden email]

> Le 18 mai 2020 à 22:50, Murray Eisenberg <[hidden email]> a écrit :
>
> Is the regex search for  "\b*$” equivalent to what Martin Costabel suggested, to use " *$” ??
>
>> On 18 May2020, at 4:38 PM, Luis Sequeira <[hidden email]> wrote:
>>
>> Murray, a few comments on your comments:
>>
>> (a) This method is possible only when using the OgreKit Find Panel.
>>
>> True. I have always used OgreKit. I do remember there were other options, but OgreKit is so much more flexible.
>>
>>
>> (b) It does not work as I?d expect if there are trailing blanks in one of the block?s lines, as it leaves those unwanted blanks there.
>>
>> This one is very easy.
>> Just replace the find regular expression to include any number of blanks before the end of the line.
>>
>> Instead of "$", search for "\b*$"
>>
>> Incidentally, regular expressions are not that hard to figure out.
>> I use them a lot, both in TeXShop and BBEdit (and good'ole vi...)
>>
>> (c) [of course] one also has to check the ?Selection? option of the Scope section in the OgreKit Find Panel.
>>
>> I did write that!
>>
>>
>>
>> Also: yes, it would be nice to have a macro for it, and I have no doubt one can be created, but I have not looked much into it.
>>
>> Regards
>>
>> LS
>> ----------- Please Consult the Following Before Posting -----------
>> TeX FAQ: http://www.tex.ac.uk/faq
>> List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
>> List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
>>               https://email.esm.psu.edu/pipermail/macosx-tex/
>> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
>> List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
>
> ---
> Murray Eisenberg [hidden email]
> 503 King Farm Blvd #101 Home (240)-246-7240
> Rockville, MD 20850-6667 Mobile (413)-427-5334
>
>
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
> List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
>                https://email.esm.psu.edu/pipermail/macosx-tex/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex

----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://sites.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
                https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex