@node Making changes, Style, How to enter data, Top
@chapter Making Changes


@menu
* Copying::             Copying cells and regions
* Moving::              Moving Cells and regions
* Deleting::            Deleting cells and regions        
* Insertion::           Inserting a new row or column
@end menu

@node Copying, Moving, Making changes, Making changes
@section Copying 
Both the cells, and the calculated values in the cells, can be copied
from one location to another. Note, however, that any relative cell
addresses present in formulas will refer to different cells -- those at
the same offset from the new location.  In @code{a0} mode, this means
that the relative addresses in the new locations' formula(s) will change
to reflect the new cells they refer to.


@table @kbd
@item M-c	
        Copy a region.  Given two ranges, it copies the source
range into the destination range.  If the destination range size is a
multiple of the source range size, the source range is copied
multiple times.  If the destination range is given as a cell, that
cell is the location of the top-left corner of the destination range.
(@code{copy-region})
@cmindex copy-region
@item M-C-c
Copy just the values of one region to another.
(@code{copy-values-in-region})
@cmindex copy-values-in-region
@end table
@kindex  M-C-c
@kindex  M-c	

Consider the  spreadsheet, where @code{B2} contains @code{@@sum(C2.D2)}:

@example

             | Col B | Col C | Col D |
       ------|-------|-------|-------|
       Row 2 |   8   |   3   |   5   |
       ------|-------|-------|-------|
       Row 3 |       |   4   |   2   |
       ------|-------|-------|-------|
       Row 4 |       |   1   |   3   |
       ------|-------|-------|-------|

@end example

If you type @code{@kbd{M-c} B2 @key{RET} B3.B4}, then @code{B2} is
unchanged, but @code{B3} contains @code{@@sum(C3.D3)}, since it was
copied from a formula with relative addresses. Similarly, @code{B4}
contains @code{@@sum(C4.D4)}.  The display shows

@example

             | Col B | Col C | Col D |
       ------|-------|-------|-------|
       Row 2 |   8   |   3   |   5   |
       ------|-------|-------|-------|
       Row 3 |   6   |   4   |   2   |
       ------|-------|-------|-------|
       Row 4 |   4   |   1   |   3   |
       ------|-------|-------|-------|

@end example

If you had typed @code{@kbd{M-C-c} B2 @key{RET} B3.B4}, then @code{B2}
is unchanged, @code{B3} contains 8, @code{B4} contains 8, and the
display shows

@example

             | Col B | Col C | Col D |
       ------|-------|-------|-------|
       Row 2 |   8   |   3   |   5   |
       ------|-------|-------|-------|
       Row 3 |   8   |   4   |   2   |
       ------|-------|-------|-------|
       Row 4 |   8   |   1   |   3   |
       ------|-------|-------|-------|

@end example

@node Moving, Deleting, Copying, Making changes
@section Moving Cells and Regions

@table @kbd
@item M-m
This is similar to copy-region, except that the source region is erased
after the copy.  The two ranges must be the same size.  Relative
addresses and variables whose ranges are inside the source region are
adjusted, as with @code{copy-region}. @footnote{This can be subtle -
some good examples are needed}
 (@code{move-region})
@cmindex move-region
@end table
@kindex  M-m

Consider the previous spreadsheet, where @code{B2} contains
@code{@@sum(C2.D2)}.

@example

             | Col B | Col C | Col D |
       ------|-------|-------|-------|
       Row 2 |   8   |   3   |   5   |
       ------|-------|-------|-------|
       Row 3 |       |   4   |   2   |
       ------|-------|-------|-------|
       Row 4 |       |   1   |   3   |
       ------|-------|-------|-------|

@end example

If we type @code{@kbd{M-m}  B2  @key{RET}  B3}, then @code{B2} is empty,
@code{B3} contains @code{@@sum(C3.D3)}, and the display shows 

@example

             | Col B | Col C | Col D |
       ------|-------|-------|-------|
       Row 2 |       |   3   |   5   |
       ------|-------|-------|-------|
       Row 3 |   6   |   4   |   2   |
       ------|-------|-------|-------|
       Row 4 |       |   1   |   3   |
       ------|-------|-------|-------|

@end example


@node Deleting, Insertion, Moving, Making changes
@section Deleting

@table @kbd
@item C-k
@cmindex delete-row
        Delete the current row.  With an argument count it deletes
several rows. (@code{delete-row}) For instance, to delete the row
containing the cell cursor, and the next 4 rows, type @code{C-u 5 C-k}.
@item M-k
        Delete the current column.  With an argument count it deletes
several columns. (@code{delete-col}) For instance, to delete the column that
@cmindex delete-col
the cell cursor is in, and the 3 columns to the right, type @code{C-u 4 M-k}.
@item M-C-?
Delete the contents (value, formula, format, etc) of a
region.  This DOES NOT ask for confirmation.
        (@code{delete-region})
@cmindex delete-region
@item M-x clear-spreadsheet
        This is an extreme action!  Erase all the values in the cells,
and reset all the heights and widths.
@end table
@kindex  M-C-?
@kindex  M-k
@kindex  C-k
@cmindex clear-spreadsheet

@node Insertion,  , Deleting, Making changes
@section Inserting Rows and Columns

These commands insert blank rows and columns.


@table @kbd
@item C-o
        Insert a row above the cell cursor.  With an argument count it adds
several rows. (@code{insert-row}) For instance, to add 5 rows above
@cmindex insert-row
the cell cursor, type @code{C-u 5 C-o}.
@item M-o
        Insert a column to the left of the cell cursor.  With an
argument count it adds several columns. (@code{insert-col}) For instance,
@cmindex insert-col
to add 4 rows to the left of  the cell cursor, type @code{C-u 4 M-o}.
@end table
@kindex  M-o
@kindex  C-o
