<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to automatically add space on both sides of the operator]]></title><description><![CDATA[<p dir="auto">How to automatically add spaces on both sides of the operator.<br />
For example, a=a+1;<br />
A = a + 1;</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/15489/how-to-automatically-add-space-on-both-sides-of-the-operator</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 13:42:27 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/15489.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Mar 2018 13:34:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Tue, 17 Apr 2018 04:09:28 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">You could try to use “find and replace” feature, set to consider regular expressions, and replace all no-space (x) char with x followed a space in a current selection.</p>
<p dir="auto">Save it as a macro and apply in other parts of code.<br />
<a href="https://10bestgame.com/instagram-cool-captions/" rel="nofollow ugc">https://10bestgame.com/instagram-cool-captions/</a></p>
</blockquote>
]]></description><link>https://community.notepad-plus-plus.org/post/31706</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31706</guid><dc:creator><![CDATA[Fahim Anwer]]></dc:creator><pubDate>Tue, 17 Apr 2018 04:09:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Wed, 04 Apr 2018 15:21:28 GMT]]></title><description><![CDATA[<p dir="auto">Thank you all for answering questions</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31436</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31436</guid><dc:creator><![CDATA[成轩]]></dc:creator><pubDate>Wed, 04 Apr 2018 15:21:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Wed, 04 Apr 2018 14:44:36 GMT]]></title><description><![CDATA[<p dir="auto">I also hope that such a plugin can be selected for different languages. I hope it can automatically determine the operator I entered and then automatically add spaces. Although regular expression processing can achieve the above operations, I think it is not too friendly and convenient</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31435</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31435</guid><dc:creator><![CDATA[成轩]]></dc:creator><pubDate>Wed, 04 Apr 2018 14:44:36 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Tue, 03 Apr 2018 10:27:21 GMT]]></title><description><![CDATA[<p dir="auto">Maybe this issue would be a case to new feature request (or plugin suggestion) in a way to put spaces between chars of current line, and the user lists in a field the sequences that wouldn’t applied  (ex. ++, —,…). There would be a general sequence list and others to each language.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31411</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31411</guid><dc:creator><![CDATA[gwarah]]></dc:creator><pubDate>Tue, 03 Apr 2018 10:27:21 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Fri, 30 Mar 2018 12:26:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/11665">@vtech7</a></p>
<p dir="auto">Hmmm…or just put the spaces in by this process:</p>
<ul>
<li>position the caret appropriately</li>
<li>press the space bar once</li>
<li>REPEAT above steps until desired effect is achieved</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/31327</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31327</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Fri, 30 Mar 2018 12:26:58 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Fri, 30 Mar 2018 08:32:50 GMT]]></title><description><![CDATA[<p dir="auto">I just forgot to mention that the above find and replace must apply 2 times (for the given sample code).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31323</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31323</guid><dc:creator><![CDATA[vtech7]]></dc:creator><pubDate>Fri, 30 Mar 2018 08:32:50 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Fri, 30 Mar 2018 06:33:17 GMT]]></title><description><![CDATA[<p dir="auto">Hi, in order to convert the following sample of code:</p>
<p dir="auto">x=(((a+5)/(z-7/b)-sin(30))*Log(6))</p>
<p dir="auto">to this one: (without double spacing)</p>
<p dir="auto">x = ( ( ( a + 5 ) / ( z - 7 / b ) - sin ( 30 ) ) * Log ( 6 ) )</p>
<p dir="auto">find:</p>
<p dir="auto">(([\w])([^\w|\s]))|(([^\w|\s])([\w]))|(([^\w|\s])([^\w|\s]))</p>
<p dir="auto">replace:</p>
<p dir="auto">(?1\2 \3)(?4\5 \6)(?7\8 \9)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31322</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31322</guid><dc:creator><![CDATA[vtech7]]></dc:creator><pubDate>Fri, 30 Mar 2018 06:33:17 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Thu, 29 Mar 2018 12:02:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/9617">@Gogo-Neatza</a> said:</p>
<blockquote>
<p dir="auto">Spend less than ten seconds to write your own Macro !</p>
</blockquote>
<p dir="auto">I’m not sure how THAT is helpful in any way…please explain if you can…</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said:</p>
<blockquote>
<p dir="auto">…the statement “x=(((a+5)/(z-7/b)-sin(30))*Log(6))” would be … “x = ( ( ( a + 5 ) / ( z - 7 / b ) - sin ( 30 ) ) * Log ( 6 ) )” with…too many space characters</p>
</blockquote>
<p dir="auto">It is very subjective (i.e., everybody likes it their own way), but I definitely agree that this is <em>too spacey</em>:</p>
<pre><code class="language-z">x = ( ( ( a + 5 ) / ( z - 7 / b ) - sin ( 30 ) ) * Log ( 6 ) )
</code></pre>
<p dir="auto">but I like this version, which doesn’t add space adjacent to <code>(</code> or <code>)</code> :</p>
<pre><code class="language-z">x = (((a + 5) / (z - 7 / b) - sin(30)) * Log(6))
</code></pre>
<p dir="auto">The original is just <em>visually painful</em> …ouch! :</p>
<pre><code class="language-z">x=(((a+5)/(z-7/b)-sin(30))*Log(6))
</code></pre>
<p dir="auto">I think I will make the modification to the regex to avoid the “too spacey” condition and then record it as a <strong>Replace All, In Selection</strong> macro, for handy use when I get a short snippet of code from (e.g.) stackoverflow and don’t like the original whitespacing of an equation.  (Is this what <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/9617">@Gogo-Neatza</a> meant?!)</p>
<p dir="auto">BTW, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a>, I like this <a href="http://www.epochconverter.com/" rel="nofollow ugc">site for timestamp conversion</a>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31291</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31291</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Thu, 29 Mar 2018 12:02:36 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Thu, 29 Mar 2018 00:29:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/11624">@成轩</a> : Spend less than ten seconds to write your own Macro !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31283</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31283</guid><dc:creator><![CDATA[Gogo Neatza]]></dc:creator><pubDate>Thu, 29 Mar 2018 00:29:53 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Wed, 28 Mar 2018 22:32:48 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/11624">@成轩</a> and <strong>All</strong></p>
<p dir="auto">Without <strong>additional</strong> information, it’s quite <strong>hard</strong> to plan anything ! Which <strong>language</strong> are you using ?</p>
<p dir="auto">Anyway, I tried to find out a correct <strong>regex</strong> S/R, which :</p>
<ul>
<li>
<p dir="auto"><strong>Trims</strong> any <strong>trailing</strong> horizontal <strong>blank</strong> characters, before the <strong>End of Line</strong></p>
</li>
<li>
<p dir="auto"><strong>Keeps</strong> any <strong>leading</strong> indentation</p>
</li>
<li>
<p dir="auto"><strong>Keeps</strong> the <strong>blank</strong> characters in any range <strong><code>".........."</code></strong>, too</p>
</li>
<li>
<p dir="auto"><strong>Deletes</strong> any range of <strong>horizontal blank</strong> characters, before a <strong>comma</strong></p>
</li>
<li>
<p dir="auto"><strong>Normalizes</strong> to a <strong>single space</strong> character, <strong>any</strong> range of <strong>blank</strong> characters, even <strong>none</strong>, <strong>PRECEDING</strong>, either :</p>
<ul>
<li>
<p dir="auto">Any <strong>consecutive</strong> range of symbols <strong><code>!  "  #  $  %  &amp;  '  *  +  -  /  :  ;  =  ?  @  \  ^  |  ~</code></strong></p>
</li>
<li>
<p dir="auto">Any <strong>single</strong> symbol <strong><code>[  ]  (  )  &lt;  &gt;  {  }</code></strong></p>
</li>
<li>
<p dir="auto">Any <strong>consecutive</strong> range of <strong>word</strong> characters or <strong>dot</strong> <strong><code>Letter  Digit  _  .</code></strong></p>
</li>
</ul>
</li>
</ul>
<p dir="auto">Of course, there are still <strong>few weird</strong> results ! For instance, the sentence <em>“On the 10/27 of that year”</em> would become <em>“On the 10 / 27 of that year”</em> but that other sentence <em>“The value x=a*10/27+b”</em> would produce the sentence <em>“The value x = a * 10 / 27 + b”</em> which is <strong>quite</strong> correct !</p>
<p dir="auto">For example, the statement <em>“x=(((a+5)/(z-7/b)-sin(30))*Log(6))”</em> would be developed as <em>“x = ( ( ( a + 5 ) / ( z - 7 / b ) - sin ( 30 ) ) * Log ( 6 ) )”</em> with, certainly, <strong>too many space</strong> characters than necessary ;-))</p>
<hr />
<p dir="auto">A <strong>last</strong> example : here is, below, a simple <strong>Python</strong> script, regarding <strong>Unix Timestamp</strong>,  with a very, very <strong>bad</strong> presentation ! You may select the option <strong>View &gt; Show Symbol &gt; Show All Characters</strong> to visualize all the <strong>blank</strong> characters</p>
<pre><code class="language-py">Day        =        28			
Month=3
Year		=			2018
Hours			=15                
Minutes=19
Seconds		=0
		                    
			# This small script get any Unix Timestamp
			#        with the different time variables above
			#        		defined with a correct numeric value

Leap=int(Year    %4==0)-int(     Year%100==0)+int(Year%400==0)                            # = 1 if a is a LEAP year, = 0 if NOT

Leap_Years=(Year      -1)//4-(Year-1)     //100+(Year-1)//400-477                           # = TOTAL of LEAP years, from 1970 to the year (Year-1)
			
Calendar_Day   =   round(30.57*(Month-1)-2*int(Month   &gt;   2))+Day+int(Leap==1)		*		int(Month&gt;2) # = TOTAL of days, from the 01/01 of Year, to Day, included

Total_Days=(Year-1970)*365+Leap_Years+Calendar_Day-1                             # = TOTAL of days, from 01/01/1970, till (Day-1) of Year
                                  
Unix_Time=Total_Days*86400+3600*Hours    +       60*Minutes+Seconds                          #  UNIX time, in seconds


print("And,    here are.... the     results  :  ",Leap       ,Leap_Years,          Calendar_Day,Total_Days,Unix_Time, "&lt;     Good Bye     &gt;")

        # The results are :
		
		# Leap=0
        #		Leap_Year		=		12
        # Calendar_Day = 87
        #            Total_Days = 17618
        # Unix_Time		=					1522250340
</code></pre>
<hr />
<ul>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong><code>Ctrl + H</code></strong> )</p>
</li>
<li>
<p dir="auto">In the <strong>Find what:</strong> zone, type in the regex :</p>
</li>
</ul>
<pre><code class="language-diff">(?-s)(\h+\R)|(\h*,)|(^)?\h*(".*?"|[]()&lt;&gt;{}[]|[!"#$%&amp;'*+/:;=?@\\^`|~-]+|[\w.]+)
</code></pre>
<ul>
<li>In the <strong>Replace with:</strong> zone, type in the regex</li>
</ul>
<pre><code class="language-diff">(?1\r\n:(?2,:(?3$0:\x20\4)))
</code></pre>
<ul>
<li>
<p dir="auto">Tick the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Click, <strong>once</strong>, on the <strong><code>Replace All</code></strong> button ( or <strong>several</strong> times on the <strong><code>Replace</code></strong> button</p>
</li>
</ul>
<p dir="auto">Et voilà ! You should get the following <strong>new</strong> text :</p>
<pre><code class="language-py">Day = 28
Month = 3
Year = 2018
Hours = 15
Minutes = 19
Seconds = 0

			# This small script get any Unix Timestamp
			# with the different time variables above
			# defined with a correct numeric value

Leap = int ( Year % 4 == 0 ) - int ( Year % 100 == 0 ) + int ( Year % 400 == 0 ) # = 1 if a is a LEAP year, = 0 if NOT

Leap_Years = ( Year - 1 ) // 4 - ( Year - 1 ) // 100 + ( Year - 1 ) // 400 - 477 # = TOTAL of LEAP years, from 1970 to the year ( Year - 1 )

Calendar_Day = round ( 30.57 * ( Month - 1 ) - 2 * int ( Month &gt; 2 ) ) + Day + int ( Leap == 1 ) * int ( Month &gt; 2 ) # = TOTAL of days, from the 01 / 01 of Year, to Day, included

Total_Days = ( Year - 1970 ) * 365 + Leap_Years + Calendar_Day - 1 # = TOTAL of days, from 01 / 01 / 1970, till ( Day - 1 ) of Year

Unix_Time = Total_Days * 86400 + 3600 * Hours + 60 * Minutes + Seconds # UNIX time, in seconds


print ( "And,    here are.... the     results  :  ", Leap, Leap_Years, Calendar_Day, Total_Days, Unix_Time, "&lt;     Good Bye     &gt;" )

        # The results are :

		# Leap = 0
        # Leap_Year = 12
        # Calendar_Day = 87
        # Total_Days = 17618
        # Unix_Time = 1522250340
</code></pre>
<p dir="auto">Of course, the <strong>trailing comments</strong> and, generally, the possible <strong>lists</strong> are not <strong>aligned</strong>, too :-( Anyway, I just ran that <strong>Python3</strong> script, <strong>after</strong> the S/R modifications, <strong>without</strong> any trouble !</p>
<p dir="auto">You may use this <a href="https://www.unixtimestamp.com/index.php" rel="nofollow ugc">Unix Timestamp Converter</a> to <strong>verify</strong> my calculus !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
<p dir="auto"><strong>P.S.</strong> :</p>
<ul>
<li>
<p dir="auto">This <strong>Python</strong> example is quite <strong>raw</strong> and simple ! My <strong>initial</strong> program, about conversions <strong>Date &lt;–&gt; Unix Timestamp</strong>, was written in the old <strong>Qbasic</strong> language and some months ago, I simply translated the <strong>main</strong> part, as an <strong>Python3</strong> exercise , about <strong>mathematics</strong> ;-))</p>
</li>
<li>
<p dir="auto">About <strong>00h30</strong>, in <strong>France</strong> ! So, I’m a bit <strong>lazy</strong> to explain <strong>how</strong> this <strong>regex</strong> S/R works ! May be <strong>next</strong> time, if you offer me… some <strong>beer</strong> ;-))</p>
</li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/31275</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31275</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 28 Mar 2018 22:32:48 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Wed, 28 Mar 2018 11:25:15 GMT]]></title><description><![CDATA[<p dir="auto">The workaround I ve suggested at the last post doesn t work in such cases</p>
<p dir="auto">ab=ab+1;</p>
<p dir="auto">But even so, I believe “find and replace” with a better regEx you will find out a solution.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31239</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31239</guid><dc:creator><![CDATA[gwarah]]></dc:creator><pubDate>Wed, 28 Mar 2018 11:25:15 GMT</pubDate></item><item><title><![CDATA[Reply to How to automatically add space on both sides of the operator on Wed, 28 Mar 2018 10:13:53 GMT]]></title><description><![CDATA[<p dir="auto">You could try to use “find and replace” feature, set to consider regular expressions, and replace all no-space (x) char with x followed a space in a current selection.</p>
<p dir="auto">Save it as a macro and apply in other parts of code.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31237</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31237</guid><dc:creator><![CDATA[gwarah]]></dc:creator><pubDate>Wed, 28 Mar 2018 10:13:53 GMT</pubDate></item></channel></rss>