Is there a way to duplicate a line?

1,155 views
Skip to first unread message

daedalus

unread,
Oct 22, 2009, 5:35:20 PM10/22/09
to BBEdit Talk
I'm coming from Windows where most of the editors I used had a built-
in way to duplicate a line. I cannot seem to locate that functionality
in BBEdit. Is there a built-in way I'm just overlooking or a macro or
something I can do that would allow me to accomplish this?

Thanks,
Richard

Dennis

unread,
Oct 22, 2009, 5:52:31 PM10/22/09
to bbe...@googlegroups.com
On Oct 22, 2009, at 2:35 PM, daedalus wrote:

> Is there a built-in way I'm just overlooking or a macro or
> something I can do that would allow me to accomplish this?

Easily done with a script:

http://www.entropy.ch/blog/Mac+OS+X/2008/05/25/BBEdit-AppleScript-Improved-Duplicate-Lines-and-Select-Lines.html

-Dennis

Doug McNutt

unread,
Oct 22, 2009, 6:20:01 PM10/22/09
to bbe...@googlegroups.com
At 14:52 -0700 10/22/09, Dennis wrote:
>On Oct 22, 2009, at 2:35 PM, daedalus wrote:
>> Is there a built-in way I'm just overlooking or a macro or
>> something I can do that would allow me to accomplish this?
>
>Easily done with a script:

If you turn it on BBEdit will select a whole line with a single click when the mouse is positioned at the very left end of a line. The editing cursor changes to a left pointing arrow.

It's really handy for worksheets when you want to execute a line but it would also work for a select, copy, paste, paste sequence.

--
--> So are we going to celebrate the start of a new decade at the end of this year? Or do the tens start at in January 2011? <--

Jonathan Lundell

unread,
Oct 22, 2009, 6:33:03 PM10/22/09
to BBEdit Talk
On Oct 22, 3:20 pm, Doug McNutt <dougl...@macnauchtan.com> wrote:
> At 14:52 -0700 10/22/09, Dennis wrote:
>
> >On Oct 22, 2009, at 2:35 PM, daedalus wrote:
> >> Is there a built-in way I'm just overlooking or a macro or
> >> something I can do that would allow me to accomplish this?
>
> >Easily done with a script:
>
> If you turn it on BBEdit will select a whole line with a single click when the mouse is positioned at the very left end of a line. The editing cursor changes to a left pointing arrow.
>
> It's really handy for worksheets when you want to execute a line but it would also work for a select, copy, paste, paste sequence.

Or triple-click, copy, paste, paste.

Christopher Stone

unread,
Oct 22, 2009, 6:38:48 PM10/22/09
to bbe...@googlegroups.com
On Oct 22, 2009, at 17:20, Doug McNutt wrote:

> If you turn it on BBEdit will select a whole line with a single
> click when the mouse is positioned at the very left end of a line.
> The editing cursor changes to a left pointing arrow.
>
> It's really handy for worksheets when you want to execute a line but
> it would also work for a select, copy, paste, paste sequence.

______________________________________________________________________

Command-L == Select Line

Command-Option-L == Select Paragraph

--
Chris

Ted Burger

unread,
Oct 22, 2009, 7:29:46 PM10/22/09
to bbe...@googlegroups.com

Or triple click the line, hold down Option, Drag and Drop

Ted
*********************** Ted Burger ****************************
t...@tobsupport.com ********* www.tobsupport.com



Mike Conley

unread,
Oct 23, 2009, 4:09:36 AM10/23/09
to BBEdit Talk
> --> So are we going to celebrate the start of a new decade at the end of this year? Or do the tens start at in January 2011? <--

Yes (for varying definitions of 'we'), and yes.

Johan Solve

unread,
Oct 23, 2009, 4:43:59 AM10/23/09
to bbe...@googlegroups.com

Here are a couple of scripts I wrote that I use almost daily. I've mapped them to cmd-opt-up and cmd-opt-down. The line at the selection point or all lines that the current selection touches will be duplicated. The resulting selection will be the entire duplicated lines.

I also have corresponding scripts to move line(s) upwards and downwards, but they are a little bit buggy (I haven't been able to work around all edge case quirks) so I don't include them here, but they are mapped to cmd-ctrl-up/down.

----------------------------------------
-- Duplicate line(s) downwards
-- Johan Sölve 2008-12-20
tell application "BBEdit"
set selStart to (startLine of selection)
set selEnd to (endLine of selection)
set seloffset to (characterOffset of selection)
set selLength to (length of selection)
if selLength > 1 then
-- check if full lines are selected, in that case deselect the trailing linebreak
select (characters seloffset thru (seloffset + selLength - 2) of document 1)
if (endLine of selection) < selEnd then set selEnd to (endLine of selection)
else if selLength = 1 then
-- a single character can only be a single line, but a selected empty line looks like two lines, fix this
set selEnd to selStart
end if
set copylines to contents of (lines selStart thru selEnd) of document 1
-- insert after last line of selection
select insertion point after line selEnd of document 1
set selection to return & copylines
-- we have a new selection now, deselect the leading linebreak to make repeated duplicates work properly
set seloffset to (characterOffset of selection)
set selLength to (length of selection)
select (characters (seloffset + 1) thru (seloffset + selLength - 1) of document 1)
end tell

----------------------------------------
-- Duplicate line(s) upwards
-- Johan Sölve 2008-12-20
tell application "BBEdit"
set selStart to (startLine of selection)
set selEnd to (endLine of selection)
set seloffset to (characterOffset of selection)
set selLength to (length of selection)
if selLength > 1 then
-- check if full lines are selected, in that case deselect the trailing linebreak
select (characters seloffset thru (seloffset + selLength - 2) of document 1)
if (endLine of selection) < selEnd then set selEnd to (endLine of selection)
else if selLength = 1 then
-- a single character can only be a single line, but a selected empty line looks like two lines, fix this
set selEnd to selStart
end if
set copylines to contents of (lines selStart thru selEnd of document 1)
-- insert before first line of selection
select insertion point before line selStart of document 1
set selection to copylines & return
-- we have a new selection now, deselect the trailing linebreak to make repeated duplicates work properly
set seloffset to (characterOffset of selection)
set selLength to (length of selection)
select (characters seloffset thru (seloffset + selLength - 2) of document 1)
end tell

--
Johan Sölve [FSA Member, Lasso Partner]
Web Application/Lasso/FileMaker Developer
MONTANIA SOFTWARE & SOLUTIONS
http://www.montania.se mailto:jo...@montania.se
(spam-safe email address, replace '-' with 'a')

daedalus

unread,
Oct 23, 2009, 1:07:06 PM10/23/09
to BBEdit Talk
Thank you everyone for your tips and suggestions. I'm going to try
them out and see what works best.

Richard

Robert A. Rosenberg

unread,
Oct 27, 2009, 12:46:23 AM10/27/09
to bbe...@googlegroups.com, BBEdit Talk, daedalus
At 14:35 -0700 on 10/22/2009, daedalus wrote about Is there a way to
duplicate a line?:

Highlight the line and Option Drag it.

Robert A. Rosenberg

unread,
Oct 27, 2009, 12:46:08 AM10/27/09
to bbe...@googlegroups.com
At 16:20 -0600 on 10/22/2009, Doug McNutt wrote about Re: Is there a
way to duplicate a line?:

>So are we going to celebrate the start of a new decade at the end of

>this year? Or do the tens start at in January 2011?

2011. There was no Year 0 (it went from 1 BCE/BC to 1 ACE/AD) so
decades run from xxx1 to xxx0). This is the same reason why the 21st
Century/ 3rd Millennium started in 2001 not (as many
thought/celebrated) in 2000 confusing the Year 2K computer problem
with the start/end of the Century/Millennium.

Stan Ulrich

unread,
Nov 5, 2009, 7:01:57 PM11/5/09
to bbe...@googlegroups.com
This is true about no Year Zero. BUT the consequence is that the first century had only 99 years. Every other century has 100. Otherwise things aren't common sensical and pedants insist on arguing with history and popular culture.

So, too, the decades would be wrong -- the Gay 90s would start in 1891 and run to 1900. The 50s, I think we can agree, run from 1950-1959, and if decades are to exist co-extensive within their centuries, then centuries need to start with the zero year, e.g., 1800, 1900, 2000.

Everything works fine if you accept that the first century took the hit on the absence of Year Zero. That is where the problem started, so the problem should be solved where it occurred.

It really makes sense and you'll avoid all that anguish if you accept that the first century (an artificial construct anyway) had only 99 years, since it was missing its Year Zero -- the rest of the centuries have theirs. This is a fact for the civil calendar, as opposed to the astronomical calendar.

This is an issue in ancient calender studies, such as the Maya calendar, because calendar correlations, typically using Julian Day Numbers, need to know whether there is a Year Zero. Things have settled down mostly now, but for a while back in the 50s-80s (1950-1989!!) some major Mayanists got it wrong and messed up by a year looking forward or backward by including a Year Zero in their calculations.

Trust me...

SU

Dennis

unread,
Nov 5, 2009, 9:26:07 PM11/5/09
to BBEdit Talk
On Nov 5, 4:01 pm, Stan Ulrich <xto...@gmail.com> wrote:
> This is an issue in ancient calender studies, such as the Maya calendar, because calendar correlations, typically using Julian Day Numbers, need to know whether there is a Year Zero.

Way off topic, but a fascinating read none the less. Thanks, Stan.

-Dennis

Doug McNutt

unread,
Nov 5, 2009, 11:39:56 PM11/5/09
to bbe...@googlegroups.com

Before we get kicked off. . .

Was the year 0000 represented by Roman numeral I for the first year after the epoch?

If so is year MMX or MMIX ?
--

--> From the U S of A, the only socialist country that refuses to admit it. <--

Robert A. Rosenberg

unread,
Nov 6, 2009, 12:37:28 AM11/6/09
to bbe...@googlegroups.com
At 17:01 -0700 on 11/05/2009, Stan Ulrich wrote about Counting years
[WAS Re: Is there a way to duplicate a line?:

>On 10/27/09, Robert A. Rosenberg wrote:
>>At 16:20 -0600 on 10/22/2009, Doug McNutt wrote about Re: Is there a
>>way to duplicate a line?:
>>
>>>So are we going to celebrate the start of a new decade at the end of
>>>this year? Or do the tens start at in January 2011?
>>
>>2011. There was no Year 0 (it went from 1 BCE/BC to 1 ACE/AD) so
>>decades run from xxx1 to xxx0). This is the same reason why the 21st
>>Century/ 3rd Millennium started in 2001 not (as many
>>thought/celebrated) in 2000 confusing the Year 2K computer problem
>>with the start/end of the Century/Millennium.
>
>This is true about no Year Zero. BUT the consequence is that the
>first century had only 99 years. Every other century has 100.
>Otherwise things aren't common sensical and pedants insist on
>arguing with history and popular culture.
>
>So, too, the decades would be wrong -- the Gay 90s would start in
>1891 and run to 1900.

The gay 90's refers to the years numbered 189x (ie: 1890-1899). It is
not the same as the 190'th decade (which is 1891-1900).

>The 50s, I think we can agree, run from 1950-1959, and if decades
>are to exist co-extensive within their centuries, then centuries
>need to start with the zero year, e.g., 1800, 1900, 2000.

The Decade/Century/Millennium is a 10/100/1000 year span and is
measured from the theoretical DAY 1 of the Year 1. They all end on
December 31 of the year numbered XXX0. This is the same difference as
measuring your age as years since your birthday (ie: Counting
Birthdays) vs years you have lived (counting from your birth - at Age
1 you are starting the 2nd year of your life).

>
>Everything works fine if you accept that the first century took the
>hit on the absence of Year Zero. That is where the problem started,
>so the problem should be solved where it occurred.
>
>It really makes sense and you'll avoid all that anguish if you
>accept that the first century (an artificial construct anyway) had
>only 99 years, since it was missing its Year Zero -- the rest of the
>centuries have theirs. This is a fact for the civil calendar, as
>opposed to the astronomical calendar.
>
>This is an issue in ancient calender studies, such as the Maya
>calendar, because calendar correlations, typically using Julian Day
>Numbers, need to know whether there is a Year Zero. Things have
>settled down mostly now, but for a while back in the 50s-80s
>(1950-1989!!) some major Mayanists got it wrong and messed up by a
>year looking forward or backward by including a Year Zero in their
>calculations.

You also have to take into consideration that in switching from the
Julian Calendar to the Gregorian Calendar in 1752, 11 days were
skipped (at least for England/the American Colonies) thus causing
Washington (who was born under the Old Style Calender) to not be born
on the date we celebrate as "Washington's Birthday. More days were
lost in counties that delayed the switch.

>
>Trust me...
>
>SU

Johan™Strandberg

unread,
Nov 6, 2009, 10:13:23 AM11/6/09
to bbe...@googlegroups.com
Darn fence posts...

If you are building a fence that is 100 feet long with one fence post every 10 feet, how many fence posts do you need?

Obviously (if you are a programmer) 10 is not a good answer. 9 and 11 are acceptable answers. For the rest of humanity this leads to major confusion, just like the "when was the first year of the second millennium?" question does. Answering 2000 is a bit like saying that 10 fence posts is the correct answer, and we just have to adjust the spacing of the posts.

99 years is _not_ a century, even if it is the "first" one. Just because you don't agree with the correct answer doesn't mean you can go back and change the fundamental definitions of words like "century".

Why this is so bad, branches out into a large set of potential problems, far beyond this already thoroughly digressed topic, so let me just tweak you with one little anomaly.

If then first century is 99 years, then:




Johan™Strandberg

unread,
Nov 6, 2009, 10:17:45 AM11/6/09
to bbe...@googlegroups.com
[Ops. Something fell on the keyboard and sent it prematurely. Here is the rest:]

First millennium => 999 years
First century => 99 years
First decade => 9 years
First year => 0 years ???


--j

Doug McNutt

unread,
Nov 6, 2009, 10:32:15 AM11/6/09
to bbe...@googlegroups.com

Before we get kicked off. . .

Was the year 0000 represented by Roman numeral I for the first year after the epoch?

If so is this year, 2009, MMIX or MMX ?
--

--> A fair tax is one that you pay but I don't <--

Mark Smith

unread,
Nov 6, 2009, 12:03:46 PM11/6/09
to bbe...@googlegroups.com

since admin hasn't shut this down yet (if they did, I missed the
mail), have we got room for a little more pedantry ?

On 06.11.2009, at 16:13, Johan™Strandberg wrote:

> If you are building a fence that is 100 feet long with one fence
> post every 10 feet, how many fence posts do you need?
>
> Obviously (if you are a programmer) 10 is not a good answer. 9 and
> 11 are acceptable answers.

For fence posts that don't add length to the fence (fence design
question), 11 is the only correct answer. 9 would only seem to be
acceptable to a programmer^[1] who knows that 10 can't be right, but
doesn't know anything about fences - specifically, that they need
posts at both ends.

For fences where the post contributes to the length of the fence, then
the correct answer depends on the width of the posts.

/ you were warned about pedantry.

mark.

[1]: a lot of non-programming engineers and scientists can be included
in this set.

Patrick Woolsey

unread,
Nov 6, 2009, 2:09:08 PM11/6/09
to bbe...@googlegroups.com
Good afternoon folks,

Please consider this thread officially snipped.


Regards,

Patrick Woolsey
==
Bare Bones Software, Inc. <http://www.barebones.com>
P.O. Box 1048, Bedford, MA 01730-1048

Steve Piercy

unread,
Nov 6, 2009, 2:22:59 PM11/6/09
to BBEdit Talk
On Nov 6, 7:13 am, Johan™Strandberg <johan...@gmail.com> wrote:
> Darn fence posts...
>
> If you are building a fence that is 100 feet long with one fence post every
> 10 feet, how many fence posts do you need?
>
> Obviously (if you are a programmer) 10 is not a good answer. 9 and 11 are
> acceptable answers.

If the fence encloses a region, for example a rectangular region that
is 20 feet by 30 feet, then 10 is a good answer.

--steve

Robert A. Rosenberg

unread,
Nov 6, 2009, 5:07:57 PM11/6/09
to bbe...@googlegroups.com
At 07:13 -0800 on 11/06/2009, Johanヾtrandberg wrote about Re:
Counting years [WAS Re: Is there a way to duplicate a l:

>Darn fence posts...
>
>If you are building a fence that is 100 feet long with one fence
>post every 10 feet, how many fence posts do you need?
>
>Obviously (if you are a programmer) 10 is not a good answer. 9 and
>11 are acceptable answers.

9 is only a "correct" answer if you allow the use of 5ft rails for
the edges (which are not supported at the ends) ie:

-5-P-10-P-10-P...P-10-P-5- (where -5- and -10- are respectively
5ft/10ft rails and P is the post).

The correct answer (with posts at both ends) is 11:

P-10-P-10-P...P-10-P-10-P
--

Robert A. Rosenberg
RAR Programming Systems Ltd.
Home: 845-357-0931
Cell: 646-479-1984
Fax: 646-349-4025

Reply all
Reply to author
Forward
0 new messages