Vim Tips Wiki
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 50: Line 50:
 
<pre>
 
<pre>
 
\ exe '%s:'.
 
\ exe '%s:'.
\ '\cCOPYRIGHT\s*\%((c)\|&copy;\|&amp;copy;\)\?\s*'.
+
\ '\cCOPYRIGHT\s*\%((c)\|&copy;\|&copy;\)\?\s*'.
 
\ '\%([0-9]\{4}\(-[0-9]\{4\}\)\?,\s*\)*\zs'.
 
\ '\%([0-9]\{4}\(-[0-9]\{4\}\)\?,\s*\)*\zs'.
 
\ '\('.
 
\ '\('.
Line 63: Line 63:
 
\ '&, '.strftime("%Y").':e' |
 
\ '&, '.strftime("%Y").':e' |
 
\ exe '%s:'.
 
\ exe '%s:'.
\ '\cCOPYRIGHT\s*\%((c)\|&copy;\|&amp;copy;\)\?\s*'.
+
\ '\cCOPYRIGHT\s*\%((c)\|&copy;\|&copy;\)\?\s*'.
 
\ '\%([0-9]\{4}\%(-[0-9]\{4\}\)\?,\s*\)*\zs'.
 
\ '\%([0-9]\{4}\%(-[0-9]\{4\}\)\?,\s*\)*\zs'.
 
\ '\%('.strftime("%Y").'\)\@!\([0-9]\{4\}\)'.
 
\ '\%('.strftime("%Y").'\)\@!\([0-9]\{4\}\)'.
Line 76: Line 76:
 
Summary: Replace all lines with a copyright notice, that do NOT end in the previous or current year, with a comma and the current year.
 
Summary: Replace all lines with a copyright notice, that do NOT end in the previous or current year, with a comma and the current year.
 
*'''<code>%s:</code>''' - start a "replace in all lines" search, using ':' rather than the customary '/' for clarity.
 
*'''<code>%s:</code>''' - start a "replace in all lines" search, using ':' rather than the customary '/' for clarity.
*'''<code>\cCOPYRIGHT\s*\%((c)\|&copy;\|&amp;copy;\)\?\s*</code>''' - find lines containing the copyright flag (copyright {optional symbol}) as in the simple method.
+
*'''<code>\cCOPYRIGHT\s*\%((c)\|&copy;\|&copy;\)\?\s*</code>''' - find lines containing the copyright flag (copyright {optional symbol}) as in the simple method.
 
*'''<code>\%({below}\)*</code>''' - match any number of year ranges followed by commas, but DO NOT use them for backreferences.
 
*'''<code>\%({below}\)*</code>''' - match any number of year ranges followed by commas, but DO NOT use them for backreferences.
 
:*'''<code>[0-9]\{4}\(-[0-9]\{4\}\)\?,\s*</code>''' - match a year or year range, followed by a comma and whitespace.
 
:*'''<code>[0-9]\{4}\(-[0-9]\{4\}\)\?,\s*</code>''' - match a year or year range, followed by a comma and whitespace.
Line 93: Line 93:
 
Summary: Replace all remaining lines with a copyright notice, that do NOT end in the current year (i.e. they end in the previous year), with a hyphen and the current year.
 
Summary: Replace all remaining lines with a copyright notice, that do NOT end in the current year (i.e. they end in the previous year), with a hyphen and the current year.
 
*'''<code>%s:</code>''' - start a "replace in all lines" search, using ':' rather than the customary '/' for clarity.
 
*'''<code>%s:</code>''' - start a "replace in all lines" search, using ':' rather than the customary '/' for clarity.
*'''<code>\cCOPYRIGHT\s*\%((c)\|&copy;\|&amp;copy;\)\?\s*</code>''' - find lines containing the copyright flag (copyright {optional symbol}) as in the simple method.
+
*'''<code>\cCOPYRIGHT\s*\%((c)\|&copy;\|&copy;\)\?\s*</code>''' - find lines containing the copyright flag (copyright {optional symbol}) as in the simple method.
 
*'''<code>\%({below}\)*</code>''' - match any number of year ranges followed by commas, but DO NOT use them for backreferences.
 
*'''<code>\%({below}\)*</code>''' - match any number of year ranges followed by commas, but DO NOT use them for backreferences.
 
:*'''<code>[0-9]\{4}\(-[0-9]\{4\}\)\?,\s*</code>''' - match a year or year range, followed by a comma and whitespace.
 
:*'''<code>[0-9]\{4}\(-[0-9]\{4\}\)\?,\s*</code>''' - match a year or year range, followed by a comma and whitespace.
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)