SC(1)
๐ NAME ๐
sc โ your new bestie, the spreadsheet calculator โจ (yes bestie, a spreadsheet in your terminal, we love to see it)
๐ฆ SYNOPSIS ๐ฆ
sc [-aCceMmnoqRrvx] [-P range[/address] | /address] [-W range] [file
...]
Like, that's a lot of flags, but don't panic. We're gonna go through every single one, no cap ๐
โจ DESCRIPTION โจ
okay so. The spreadsheet calculator sc (that's the sc(1) we're all here for) is built on rectangular tables, kinda exactly like a financial spreadsheet but it lives in your terminal and it's lowkey iconic. ๐
When you invoke it, here's the whole getting-ready routine, in order:
- It first looks for a file in your home directory called
.scrc, and if it finds one, it reads that file into memory. ๐ซถ - If that file contains the command
set scrc,scthen looks for a file called.scrcin the current directory, and if it finds one, it reads that into memory too. (so many dotfiles, so little time) - Next it reads the options from the command line.
- And finally it reads in the file or files you named on the command line, and presents the data in a table organized as rows and columns of cells. ๐
If you invoke it without a file argument, the table is initially empty โ unless it's running in a pipeline, in which case it'll read its data from the standard input. ๐
If you specify more than one file, all files except the first one will be merged. The default filename for saving a file with the Put command will be the same as the first file you specified, and the other files get treated as macros. If you wanna use advanced macros from the command line, the | must be quoted to stop the shell from expanding it. (the shell is nosy like that, no cap)
Options begin with -. But bestie, listen: an argument of a single - will be interpreted to mean that spreadsheet data comes from the standard input. Super useful for including sc in a pipeline, if your system supports pipes. ๐
Here's the tea though: if standard input is not a terminal, the-is only necessary if there are multiple files and standard input is not the last one to be read โ because standard input is automatically read in after all other files in such cases if it's not specified explicitly, or if there are no other filenames on the command line. Ifscis included in a pipeline and a filename of-is not specified, the standard input will be merged in after all of the other named files have been processed.
The first argument that doesn't begin with a -, or a single - by itself, and any subsequent arguments, will all be interpreted as filenames (a filename of - meaning standard input, like we just said). ๐๏ธ
In addition, an argument of -- may be used to signify that all subsequent arguments should be treated as filenames even if they begin with a -. But unlike -, -- won't be treated as a filename itself. (it's giving "just a separator, not a participant" โ)
Each cell may have associated with it:
- a numeric value,
- a label string,
- and/or an expression (formula) which evaluates to a numeric value or label string, often based on other cell values.
For an online tutorial, type the command:
sc /usr/local/share/sc/tutorial.sc
To generate a quick reference card in PDF format, type the command (for traditional troff):
scqref | troff -ms | dpost | ps2pdf - filename.pdf
Or for using groff:
scqref | troff -Tpdf -ms | gropdf > filename.pdf
๐ OPTIONS ๐
Every single flag, bestie. We're not skipping a single one, periodt. ๐
-aโ Do not run the autorun macro, if one is specified in the file. (it's on time-out ๐ซ)-cโ Start the program with the recalculation being done in column order.-eโ Start the program with round-to-even (banker's rounding) enabled. ๐ฐ-mโ Start the program with automatic recalculation disabled. The spreadsheet will be recalculated only when the@command is used. (manual mode activated, bestie is in control now)-nโ Start the program in quick numeric entry mode (see below).-oโ Start the program with automatic optimization of expressions enabled. โจ-qโ Quit after loading all files, but before becoming interactive. This is useful in shell scripts for getting information from a file, for example, or usingscas a non-interactive calculator using theevalcommand. (in and out, no small talk, we respect it)-rโ Start the program with the recalculation being done in row order (default option). โญ-vโ When piping data out using the-Poption (below), change all expressions to values. The-voption must precede the-Poption to have an effect. If the-Poption is used more than once, there must be a separate-voption for each instance of the-Poption. (they're a matched set, fr fr)-xโ Cause theGetandPutcommands (see below) to encrypt and decrypt data files. ๐-Cโ Start the program with automatic newline action set to increment the column (see below).-Mโ Process mouse events (see optionsmouse/!mouse). This option overrides aset !mousecommand in.scrc. It is used byxsc(1). ๐ฑ๏ธ-P range[/address]-P /addressโ Pipe a range to standard output. The output is similar to that of thePutcommand (below), except that only cell data and formatting information for cells in the range are output, without all of the colors, range definitions, column formatting, etc.
The optional /address is used to adjust all addresses in the range to a new starting point. This is useful for copying data from one file to another, especially when used in conjunction with the -v option (above), using something like merge "|sc -v -Prange/address filename" (note the pipe symbol). ๐ฐ
This option may be used more than once to specify multiple ranges. Note, however, that the -v option must precede the -P option on the command line, and there must be a separate -v option for each instance of the -P option. Any instance of -P not preceded by its own -v option will output unevaluated expressions.
A range of % may be used to refer to the entire spreadsheet. If the range is left out, as shown in the second form above, sc will be started interactively in navigate mode, allowing you to navigate the spreadsheet and highlight the range you want to output. Pressing <ESC>, ^G, or q will terminate without outputting any data. ๐โโ๏ธ
-Rโ Start the program with automatic newline action set to increment the row (see below).-Wโ Pipe a range to standard output. The output is identical to that of theWritecommand (below). This option may be used more than once to specify multiple ranges. A range of%may be used to refer to the entire spreadsheet. โ๏ธ
All of these options can be changed with the ^T and S commands (see below) while sc is running. Options specified when sc is invoked override options saved in the data file. (command line wins, always, no debating ๐ฅ)
๐ Personal Initialization File ๐
When sc first starts, it looks for a file in the user's home directory called .scrc, and if found, loads it into memory. The format of this file is the same as any other sc file, but it should be reserved for setting certain defaults. Any options set which have equivalent command line options may be overridden by the command line. ๐ซถ
If that file contains the command set scrc, sc will then look for a file called .scrc in the current directory, and if found, load that file into memory too (this is analogous to the set exrc command used by vi/ex). These "dotfiles" may be created by any text editor. โ๏ธ
Several commands exist specifically for setting default file name extensions in the .scrc file, although they may also be used from macros, ordinary spreadsheet files, or from within sc at the command line. They will not, however, be saved along with the file. The extensions should be quoted, and should not include the preceding . (e.g., scext "sc" will add the extension .sc). These commands are:
scextโ This is the default extension for normalscfiles (those created with thePutcommand). If this command is not used, allscfiles will be saved without an extension, and any existing extension will not be removed. Setting this option causes allscfiles to be saved with the specified extension added, unless it is already present. If the file name already has an extension of.sc, it will first be removed. Any other extension will not be removed. ๐ธascextโ This is the default extension for plain text files created with theWritecommand. The file name will first be checked to see if it already has an extension of either.scor the extension specified withscextabove, and if either one exists, it will first be removed before adding the new extension. If this option is not set, a default of.ascwill be used. ๐tbl0extโ This is the default extension for files created with theTblcommand iftblstyleis set to0(default). The file name will first be checked to see if it already has an extension of either.scor the extension specified withscextabove, and if either one exists, it will first be removed before adding the new extension. If this option is not set, a default of.clnwill be used. ๐งtblextโ This is the default extension for files created with theTblcommand iftblstyleis set totbl. The file name will first be checked to see if it already has an extension of either.scor the extension specified withscextabove, and if either one exists, it will first be removed before adding the new extension. If this option is not set, a default of.tblwill be used. ๐latexextโ This is the default extension for files created with theTblcommand iftblstyleis set tolatex. The file name will first be checked to see if it already has an extension of either.scor the extension specified withscextabove, and if either one exists, it will first be removed before adding the new extension. If this option is not set, a default of.latwill be used. ๐slatexextโ This is the default extension for files created with theTblcommand iftblstyleis set toslatex. The file name will first be checked to see if it already has an extension of either.scor the extension specified withscextabove, and if either one exists, it will first be removed before adding the new extension. If this option is not set, a default of.stxwill be used. โญtexextโ This is the default extension for files created with theTblcommand iftblstyleis set totex. The file name will first be checked to see if it already has an extension of either.scor the extension specified withscextabove, and if either one exists, it will first be removed before adding the new extension. If this option is not set, a default of.texwill be used. ๐
...and bestie, we are SO not done yet. More sections incoming, stay tuned ๐
histfile "filename"โ sets your history filename, or yeets history-saving entirely. default is~/.sc_history. if the filename starts with~/, that tilde gets expanded using whatever$HOMEis set to. if it starts with~followed by a username, it expands to that user's home directory from the password database. andhistfile ""โ empty filename โ turns off the history file completely. ๐ซถ
๐ธ GENERAL INFORMATION ๐ธ
okay bestie, let's talk screen layout, because the screen is literally split into four regions and knowing them is the whole vibe.
- the top line is where you type commands and where cell values get shown.
- the second line is for messages from sc.
- the third line plus the first four columns show the column and row numbers โ which is where cell addresses come from, like
A0for the cell in column A, row 0. and ngl, column names are case-insensitive:A0anda0are the same thing, no cap. - everything else on the screen is a window looking at a chunk of the table.
the total number of display rows and columns you have โ and therefore how many table rows and columns get displayed โ is set by curses(3) and can be overridden by setting the LINES and COLUMNS environment variables respectively. โจ
the screen has two cursors: a <b>cell cursor</b>, shown either as a highlighted cell or a โ<โ on screen, and a <b>character cursor</b>, which is the terminal's hardware cursor. two icons, one screen, main character energy. ๐
if a cell's numeric value is wider than the column width (check the f command for that), the cell gets filled with asterisks. if a cell's label string is wider than the column width, it gets truncated at the start of the next non-blank cell in the row, if there is one.
cursor control commands and row and column commands can be prefixed by a numeric argument that says how many times the command should run. and if quick numeric entry mode is enabled, you can type ^U before a repeat count. ๐
๐ CHANGING OPTIONS ๐
^Toโ Toggle options. this command lets you flip the state of one option, selected byo. a little menu lists the choices forowhen you type^T. unless it says otherwise, the options you picked get saved along with the data and formulas, so you roll up next time with the same setup. ๐aโ Automatic Recalculation. when set, every change in the spreadsheet makes the entire spreadsheet recalculate. normally you won't even notice, but for very large spreadsheets it can be faster to turn automatic recalculation off and update things yourself with explicitโ@โcommands. default is automatic recalculation on.bโ Braille enhancement mode. see the braille section under the Set command below for the full rundown on how to use this mode. this option is not saved when you save a file, so blind and sighted users can share files easily. it's meant to live in a user's.scrcfile. ๐cโ Current cell highlighting. if enabled, the current cell is highlighted (using the terminal's standout mode, if it has one) and the cell pointerโ<โis turned off. enabled by default.eโ External function execution. when disabled, external functions (see@ext()below) are not called. this saves a lot of time on every screen update. external functions are disabled by default. if they're disabled and external functions are used anywhere, a warning prints each time the screen updates, and the result of@ext()is the value from the previous call, if any, or a null string. ๐iโ Automatic insertion of rows/columns. if this is enabled andcractionis set to move the cell cursor either down or to the right after you enter data into a cell, and the last cell in a row/column in the scrolling portion of a framed range was just filled, causing the cell cursor to move outside that range, then a new column/row gets inserted โ enlarging the range so you can keep entering data into the row/column without overwriting the frame (which may hold expressions of some sort, like totals). ifautowrapis also enabled, it takes precedence, and a new row/column is only inserted after you enter data in the very last cell (bottom right corner) of the scrolling range. default is no automatic insertion.wโ Automatic wrap to next row/column. if this is enabled andcractionis set to move the cell cursor either down or to the right after entering data into a cell, and the last cell in a row/column in the scrolling portion of a framed range was just filled, causing the cell cursor to move outside that range, the cell cursor moves to the first cell in the next row/column in that range. if that would also take the cursor out of the scrolling portion of the range, the cursor stays in the last edited cell instead โ unlessautoinsertis also enabled, in which case a new row/column gets added so the cursor can wrap. default is no autowrap.lโ Autolabeling. if enabled, using the define command (rd) causes a label to be automatically generated in the cell to the left of the defined cell. this only happens if the cell to the left is empty. enabled by default. โจnโ Quick numeric entry. if enabled, a typed digit is assumed to be the start of a numeric value for the current cell, not a repeat count โ unless it's preceded by^U. also, theโ+โandโ-โkeys enter insert mode and append aโ+โorโ-โto whatever's already in the cell, so you can easily add to or subtract from the current numeric contents. the cursor controls (^P,^N, or any of the arrow keys) in this mode will end a numeric entry if that entry was started by pressingโ+โ,โ-โ, or a digit. switching from insert mode to edit mode makes the cursor controls go back to their normal functions.oโ Automatic optimization of expressions. if enabled, expressions that evaluate to a constant get automatically optimized on entry. for example, if you enter@pow(2,32)into a cell, the value4294967296gets stored in that cell โ whereas if optimization is off, the calculated value is displayed but the actual expression is what's stored in the cell instead. that way you can edit the expression instead of re-entering it from scratch when you just want a tiny change. default is automatic optimization off.tโ Top line display. if enabled, the name and value of the current cell are displayed on the top line. if there's an associated label string, the first character of the string value isโ|โfor a centered string,โ<โfor aleftstringorโ>โfor arightstring(see below), followed by"string"for a constant string or{expr}for a string expression. a constant string may be preceded with a backslash (โ\โ). in that case the constant string is used as a โwheelโ to fill a column, e.g."\-"for a line in a column, and"\Yeh "for"Yeh Yeh Ye". if the cell has a numeric value, it follows as[value], which may be a constant or expression. ๐ฆ$โ Dollar prescale. if enabled, all numeric constants (not expressions) that you enter get multipled by0.01, so you don't have to keep typing the decimal point when you're entering a ton of dollar figures. ๐ธrโ Newline action. this is a 3-way toggle that decides which direction to move after pressing the RETURN key to enter data into a cell. it does the same thing as using the set (S) command to set the value ofcraction. after picking this option, you get prompted for the direction you want to move. valid directions are down (craction=1) and to the right (craction=2). pressingj,^N, or the cursor-down key makes the cursor move down a cell each time you press RETURN, and pressingl, the cursor-right key, or the space bar makes the cursor move one cell to the right. pressing RETURN at the prompt selects no action (craction=0, which means the cursor stays in the current cell). no action is the default unless sc is started with either the-Ror-Coption. this option is ignored if the cell you're entering data into isn't the current cell. ๐sโ Enable/disable color slop. if a cell's label string is wider than the column width, it slops over into the next cell to the right if that cell is empty. but if that cell is in a different color range than the first one, this slopover gets disabled regardless of whether the colors assigned to the two ranges are different or not. ifcslopis enabled, strings may slop over even if the next cell is in a different color range โ carrying their color with them, which may cause a ragged boundary between the ranges, but may let the strings be seen in their entirety.cslopis disabled by default.xโ Encryption. see the-xoption. ๐
zโ Set newline action limits. This option sets limits to the newline action option above. When this option is invoked, the row and column of the current cell are remembered. If a later newline action would take the current cell to the right of the remembered column, then the current cell is instead moved to the first column of the next row. If a newline action would take the current cell below the remembered row, then the current cell is instead moved to the top row of the next column. โจCโ Color. This option enables color, and must be set before any other color options, such ascolorneg(color negative numbers) orcolorerr(color cells with errors), will have an effect. On a slow connection, turning off color can noticeably speed up screen updates. ๐Eโ Color cells with errors. Setting this option will cause all cells with expressions which evaluate toERRORorINVALIDto be set to color3. Color must be enabled for this option to take effect. โ ๏ธNโ Color negative numbers. When this option is set, all cells containing negative numbers will have their color number incremented by one. Cells with color8will cycle back to color1. Color must be enabled for this option to take effect. ๐
The quick numeric entry, newline action and set newline action limits options can be combined to allow very quick entry of large amounts of data. If all the data to be entered is in a single row or column then setting the quick numeric entry and the appropriate newline action will allow the numbers to be entered without any explicit commands to position the current cell or enter a number.
If the data entry involves several entries in each row for many rows, then setting the quick numeric entry option, setting the newline action to move right after each entry and setting the newline action limits on the last column on which data should be entered will allow the data to entered quickly. An alternative to setting newline action limits is to enclose the range for entry in a frame (see โFramed Rangesโ below), and setting the autowrap option. Setting autoinsert will insert new rows as needed if the frame includes data at the bottom. If necessary, columns which do not need data to be entered can be hidden with the z command. Similar arrangements can be made for entering several rows of data in each column. ๐
โจ
Sโ Set options. This command allows you to set various options. A small menu lists the options that cannot be changed through^Tabove.byrows/bycolsโ Specify the order cell evaluation when updating. These options also affect the order in which cells are filled (seerf) and whether a row or column is cleared by anxcommand. So basically row vs column vibe check. ๐iterations=nโ Set the maximum number of recalculations before the screen is displayed again. Iterations is set to10by default. So it's like the patience limit for recalcs. โจtblstyle=sโ Control the output of theTcommand.scan be:0(default) to give colon delimited fields, with no tbl control lines;tblto give colon delimited fields, withtbl(1)control lines;latexto give a LaTeX tabular environment;slatexto give a SLaTeX (Scandinavian LaTeX) tabular environment;texto give a TeX simple tabbed alignment with ampersands as delimiters; andframeto give a tblstyle output for FrameMaker. So many choices, pick your fighter. ๐pagesize=nโ Set the page size for thePageUp,PageDown,J, andKcommands. If set to0, the default is to move up or down half the number of rows displayed on the screen, or if the current cell is in a framed range, half the number of displayed rows in the scrolling region of that range. So0means auto-vibe. ๐ธ
Other Set options are normally used only in sc data files since they are available through ^T. You can also use them interactively. So they're lowkey for scripts but highkey work anytime. ๐
autocalc/!autocalcโ Set/clear auto recalculation mode. Toggle toggle. ๐autoinsert/!autoinsertโ Set/clear automatic insertion mode. Insert slay. ๐ฆautowrap/!autowrapโ Set/clear autowrap mode. Wrap it up. ๐optimize/!optimizeโ Set/clear auto optimize mode. Make it efficient. โกnumeric/!numericโ Set/clear numeric mode. Numbers only. ๐ขprescale/!prescaleโ Set/clear numeric prescale mode. Pre-scale like a queen. ๐extfun/!extfunโ Enable/disable external functions. External vibes. ๐toprow/!toprowโ Set/clear top row display mode. Keep it top. ๐ฏrndtoeven/!rndtoevenโ Default:*.5will be rounded up to the next integer; doing aset rndtoevenwill cause it to be rounded to the closest even number instead (aka banker's rounding). Round-to-even has advantages over the default rounding for some applications. For example, ifX+Yis an integer, thenX+Y = rnd(X)+rnd(Y)with round-to-even, but not always with the defaulting rounding method. This could be an advantage, for example, when trying to split an odd amount of money evenly between two people (it would determine who gets the extra penny). Note:rndtoevenonly effects the@rndand@roundfunctions. It has no effect on how a number is rounded to fit the display format of a cell. So basically it's for fair splits and avoiding bias. ๐งฎโจcraction=nโ Set the newline action.ncan be:0(default) to give no action;1to move down after each entry; or2to move right after each entry. Pick your direction. โฌ๏ธโก๏ธrowlimit=nโ Set the remembered limit for the maximum row below which the current cell will be moved to the top of the next column if the newline action is set to move the current cell down.ncan be-1(default) to disable this facility. So-1= off. ๐ซcollimit=nโ Set the remembered limit for the maximum column to the right of which the current cell will be moved to the left of the next row if the newline action is set to move the current cell right.ncan be-1(default) to disable this facility. Same-1energy. ๐color/!colorโ Enable color. This option must be set for any other color options, such ascolornegorcolorerr, to take effect. On a slow connection, turning off color can noticeably speed up screen updates. So if your net is trash, maybe turn it off. ๐ญcolorneg/!colornegโ Color negative numbers. When this option is set, all cells containing negative numbers will have their color number increased by one. Cells with color8will cycle back to color1. Color must be enabled for this option to take effect. So color first, then this. ๐colorerr/!colorerrโ Color cells with errors. Setting this option will cause all cells with expressions which evaluate toERRORorINVALIDto be set to color3. Color must be enabled for this option to take effect. Error but make it fashion. ๐cslop/!cslopโ Enable color slop. If a cell's label string is wider than the column width, it will slop over into the next cell to the right if that cell is empty. However, if that cell is in a different color range than the first, this slop over will be disabled, regardless of whether the colors assigned to the two ranges are different or not. Ifcslopis enabled, strings may slop over even if the next cell is in a different color range, carrying their color with them, which may cause a ragged boundary between the ranges, but may allow the strings to be seen in their entirety.Cslopis disabled by default. So it's like letting your text overflow with attitude. ๐
The following Set options are considered personal preferences, or are terminal dependent, and are therefore not saved when saving a file, but are instead intended for use in a user's .scrc file. So they're your personal vibe, not part of the shared doc. ๐
braille/!brailleโ Set/clear braille enhancement mode. When braille enhancement mode is set, the cursor behaves in a manner that makes the use ofscmuch easier when using a braille display. In spite of its name, this mode also works well with screen readers such as SpeakUp, and can even be used by sighted users to make cutting and pasting using thescreenprogram much easier.
There are actually two different braille modes. When the braille option is set, the C command, which is normally used to set colors, will instead change from one braille mode to the other. If it is desired to set/change colors so you can share files with others not using a braille display, braille mode will have to be switched off temporarily, and then switched back on after the color operation is done.
When the braille option is set, the default braille mode will cause the cursor to be positioned at the left edge of the current cell, while the alternate braille mode will cause the cursor to be placed at the beginning of the top line, which will contain information such as the current cell address, contents of the cell, and column formatting information. The column names will also be moved to the left edge of their respective columns in order to remain aligned with the cursor as it moves up and down the column.
In either mode, the cursor will be placed in the top line when editing a line, except when switching to navigate mode, in which case the cursor will be placed in either the current cell (default braille mode) or the second line, where the cell address or default range will be displayed (alternate braille mode). ๐ฆ๐
Whenever a message pops up on the second line โ an error message, a prompt asking for more info, whatever โ both modes are gonna yeet the cursor to the beginning of that message. ๐
Once the message dips out, the cursor reverts to its former behavior, no drama. And the easiest way to make that message go away without affecting literally anything (except in the cases where it's actually asking the user for more information, obvs) is to press CC โ which effectively changes modes twice, netting you right back in the original mode sc was already in. โจ
locale/!localeโ If locale support got compiled into sc, this option switches on certain locale-dependent behaviors, like how numbers get displayed and how word boundaries get figured out for some operations in edit mode. Heads up tho: if this option is set and the environment variableLC_ALLis unrecognized, unset, or set to either โPOSIXโ or โCโ, then commas in format commands are just gonna be ignored. ๐cellcur/!cellcurโ Set/clear current cell highlighting mode. This one's chillin' here in the options because it's likely to be terminal dependent and/or just a user preference โ which is exactly why it is not saved when saving a file. ๐scrcโ Tells sc to also read the file.scrcin the current directory when starting. Settings in this file will override those in$HOME/.scrc, but may themselves get overridden by command line options. โ ๏ธ Setting this could be a potential security risk, since starting sc with an unknown.scrccould potentially execute arbitrary commands. That risk is probs very slight, since a spreadsheet program is not likely to be run in just any directory โ and it should never be run as root. periodt.backup/!backupโ Before the database is written to an existing file, a backup of that file can be saved as filename~. This option enables/disables that whole situation. Default is not to do backups.mouse/!mouseโ Process mouse events. By default mouse support is disabled, for compatibility reasons with traditional sc. If mouse events are enabled, you gotta press the shift key to use the mouse โcut and pasteโ feature. Currently implemented: selecting cells with the left mouse button ๐ฑ๏ธ, vertical scrolling using the mouse wheel (requires ncurses version โฅ 6), and selecting the position in the edit line with the left mouse button. Iconic behavior, honestly.
๐ธ Cursor Control Commands ๐ธ
^Aโ Go to cell A0 (same as<HOME>).^Pโ Move the cell cursor up to the previous row.^Nโ Move the cell cursor down to the next row.^Hโ Move the cell cursor backward one column.<SPACE>โ Move the cell cursor forward one column. When in navigate mode, if a range is highlighted, insert the highlighted range into the command line, followed by a space, while remaining in navigate mode. This is useful when entering copy, move, or frame commands, for example, which accept more than one range argument. ๐ซถh,j,k,lโ These are alternate, vi-compatible cell cursor controls (left, down, up, right). Space is just likel(right).H,J,K,Lโ These move the cursor by half pages (left, down, up, right). If pagesize is nonzero, up/down paging will be by pagesize rows, instead.^F,^Bโ Same asJandKabove.<PAGE-DOWN>,<PAGE-UP>โ Same asJandKabove.<TAB>โ If the character cursor is on the top line,<TAB>tries to complete a range name if the character immediately preceding it is alphanumeric or โ_โ, and starts a range if not (see below). Otherwise, move the cell cursor forward one column.<HOME>โ Go to cell A0.<END>โ Same as^E(see below).<Arrow Keys>โ The terminal's arrow keys provide another alternate set of cell cursor controls if they exist and are supported in the appropriate termcap entry. Some terminals have arrow keys which conflict with other control key codes. For example, a terminal might send^Hwhen the back arrow key is pressed. In these cases, the conflicting arrow key performs the same function as the key combination it mimics. ๐ญ^โ Move the cell cursor up to row 0 of the current column.#โ Move the cell cursor down to the last valid row of the current column.0โ Move the cell cursor backward to column A of the current row. This command must be prefixed with^Uif quick numeric entry mode is enabled.$โ Move the cell cursor forward to the last valid column of the current row.bโ Scan the cursor backward (left and up) to the previous valid cell.wโ Scan the cursor forward (right and down) to the next valid cell.gโ Go to a cell. sc prompts for a cell's name, a regular expression surrounded by quotes, or a number. If a cell's name such asae122or the name of a defined range is given, the cell cursor goes directly to that cell. If a quoted regular expression such as" Tax Table "or" ^Jan [0-9]*$ "is given, sc searches for a cell containing a string matching the regular expression. Seeregex(3)ored(1)for more details on the form of regular expressions.
You can also search formatted numbers or expressions using regular expressions by preceding the opening quotes of the regular expression with a โ#โ (for formatted numbers) or a โ%โ (for expressions). These are handy for searching for dates within a specified range or cells which reference a given cell, for example, although they are somewhat slower than searching through ordinary strings, since all numbers must be formatted or expressions decompiled on the fly during the search. ๐ฅ
If a number is given, sc will search for a cell containing that number. Searches for either strings or numbers proceed forward from the current cell, wrapping back to a0 at the end of the table, and terminate at the current cell if the string or number is not found. You may also go to a cell with an ERROR (divide by zero, etc. in this cell) or INVALID (references a cell containing an ERROR). g error will take you to the next ERROR, while g invalid take you to the next INVALID. The last g command is saved, and can be re-issued by entering g<return>. You can also repeat the last search by pressing n.
An optional second argument is available whose meaning depends on whether you're doing a search or jumping to a specific cell. When doing a search, the second argument specifies a range to search. When jumping to a specific cell, the second argument specifies which cell should be in the upper lefthand corner of the screen, if possible, which allows you to position the destination cell where you want it on the screen. โจ
^Edโ Go to end of range. Follow^Eby a direction indicator such as^Porj. If the cell cursor starts on a non-blank cell, it goes in the indicated direction until the last non-blank adjacent cell. If the cell cursor starts on a blank cell, it goes in the indicated direction until the first non-blank cell. This command is useful when specifying ranges of adjacent cells (see below), especially when the range is bigger than the visible window. ๐
If ^E is pressed twice in succession, or if it is pressed after another ^E or a ^Y, it will cause the screen to scroll up without moving the cell cursor, unless the cell cursor is already at the top of the screen, in which case, it will remain at the top of the visible screen.
^Yโ Causes the screen to scroll down without moving the cell cursor, unless the cell cursor is already at the bottom of the screen, in which case, it will remain at the bottom of the visible screen.mxโ Mark the current cell. sc will prompt for a lowercase letter to be used as a mark specifier. Marked cells may be used as the source for thec(copy a marked cell) command, or as the target of a`or'(go to marked cell) command. In addition to cells marked with lowercase letters, sc also automatically marks the last nine cells that have been edited with the numbers1-9, and the current cell being edited with the number0. When not editing a cell, marks0and1usually refer to the same cell, unless the last edit was begun in one cell, but the cell address was changed before pressing the RETURN key, or the last edit was aborted prematurely. ๐`xโ Jump to a previously marked cell. If the target cell is currently on the screen, sc will simply jump to the target cell, making it current. Otherwise, sc will attempt to center the cell on the screen, if possible. As a special case, following the`with another`will return you to the cell you were in before the lastg,',`,*, or^E(or END key) was used to jump to another cell.'xโ Jump to a previously marked cell.'works just like`, except that'will attempt to restore the marked cell to the same position on the screen as when it was marked. It does this by remembering which cell was in the upper left hand corner of the screen at the time the mark was set, and restoring that cell to its original position. As a special case, following the'with another'will return you to the cell you were in before the lastg,',`,*, or^E(or END key) was used to jump to another cell, and will also try to position that cell on the screen in the same position as when you left it. ๐z<RETURN>โ Move the current row to the top of the screen. If the current row is in a framed range, move the current row to the top of the scrolling region.z.โ Move the current row to the center of the screen.z|โ Move the current column to the center of the screen.zcโ Center the current cell both horizontally and vertically.
๐ Cell Entry and Editing Commands ๐
okay bestie, this is the part where it gets real. ๐ธ So here's the tea on cells: a cell can hold a numeric value AND a string value. Either one of those can be the result of an expression โ but not both at once, like, each cell gets only one expression attached to it. periodt.
So when you enter a valid numeric expression, it changes the cell's previous numeric value (if there was one), and it replaces the cell's previous string expression (if there was one) โ leaving only the previously computed constant label string behind. And same energy the other way: entering a valid string expression changes the cell's previous label string (if any), and replaces the cell's previous numeric expression (if any), leaving only the previously computed constant numeric value. ๐
=โ Drop a numeric constant or expression into the current cell. sc hits you with a prompt on the top line. The classic move is: type=, then type the number when it asks. The quick numeric entry option (turned on with the-noption or the^Tcommand) shows the prompt the moment you type the first digit of a number, so you can literally skip typing=. โจ If you wanna start entering an expression in the current cell but you want to kick it off in navigate mode (like, to enter cell addresses, or sums of ranges using@sum), use the+command instead โ more on that below.<โ Enter a label string into the current cell, flushed left against the left edge of the cell.\โ Enter a label string into the current cell, centered in the column. ๐>โ Enter a label string into the current cell, flushed right against the right edge of the cell.{โ Left justify the string in the current cell.|โ Center the string in the current cell.}โ Right justify the string in the current cell.Fโ Enter a format string into the current cell. This format string overrides the precision specified with thefcommand โ unless&is present in the fractional part of the format string (see below, bestie). The format only applies to numeric values. There are two types of format strings allowed: standard numeric and date. (Heads up: these format strings can also be used with thefcommand to create user-defined format types. ๐)
The following characters can be used to build a standard numeric format string:
#โ Digit placeholder. If the number has fewer digits on either side of the decimal point than there are#characters in the format, the extra#characters are ignored. The number is rounded to the number of digit placeholders as there are to the right of the decimal point. If there are more digits in the number than there are digit placeholders on the left side of the decimal point, then those digits are displayed.0โ Digit placeholder. Same as for#except the number is padded with zeroes on either side of the decimal point. The number of zeroes used in padding is determined by the number of digit placeholders after the0for digits on the left side of the decimal point, and by the number of digit placeholders before the0for digits on the right side of the decimal point..โ Decimal point. Determines how many digits are placed on the right and left sides of the decimal point in the number. If locale is set, the decimal point for the user's current locale will be used when formatting a number. Note that numbers smaller than 1 will begin with a decimal point if the left side of the decimal point contains only a#digit placeholder. Use a0placeholder to get a leading zero in decimal formats. ๐ง%โ Percentage. For each%character in the format, the actual number gets multiplied by 100 (only for purposes of formatting โ the original number is left unmodified) and the%character is placed in the same position as it is in the format.,โ Thousands separator. The presence of a,in the format (multiple commas are treated as one) will cause the number to be formatted with a,separating each set of three digits in the integer part of the number, with numbering beginning from the right end of the integer. If locale is set, the thousands separator for the user's current locale will be used in place of the comma. If the environment variableLC_ALLis unset, unrecognized, or is set toPOSIXorC, any commas in the format string will be ignored.&โ Precision. When this character is present in the fractional part of the number, it is equivalent to a number of0's equal to the precision specified in the column format command. For example, if the precision is 3,&is equivalent to000.\โ Quote. This character causes the next character to be inserted into the formatted string directly with no special interpretation.E-E+e-e+โ Scientific format. Causes the number to be formatted in scientific notation. The case of theEoregiven is preserved. If the format uses a+, then the sign is always given for the exponent value. If the format uses a-, then the sign is only given when the exponent value is negative. Note that if there is no digit placeholder following the+or-, then that part of the formatted number is left out. In general, there should be one or more digit placeholders after the+or-.;โ Format selector. Use this character to separate the format into two distinct formats. The format to the left of the;character will be used if the number given is zero or positive. The format to the right of the;character is used if the number given is negative.
Some example formats are integer (0 or #), fixed (0.00), percentage (0% or 0.00%), scientific (0.00E+00), and currency ($#,0.00;($#,0.00)). ๐ธ
Date format strings are identified by the presence of a ^D in the first position. If this is present, the remainder of the string is passed to the strftime() function, and therefore uses the same conversion specifiers as strftime(). For more info on conversion specifiers for date format strings, check the man page for strftime(3).
Strings you enter must start with ". You can leave off the trailing " and sc will add it for you. ๐ซถ You can also enter a string expression by backspacing over the opening " in the prompt.
eโ Edit the value associated with the current cell. This is identical to=except the command line starts out containing the old numeric value or expression associated with the cell. The editing in this mode is vi-like. ๐^Hโ Move back a character^V,vโ Enter navigate mode. This mode lets you navigate the spreadsheet while editing a command. When in navigate mode,vwill insert the numeric value of the current cell, if any, into the command line instead โ while^Vwill return to the previous mode (like theESCAPEkey).^Wโ Insert the expression attached to the current cell into the command line. If there is none, the result is?. This only works while in navigate mode.^Aโ In navigate mode, go to cellA0. When not in navigate mode, jump to the beginning of the line instead.^Eโ Jump to the end of the line. Unlike$(below), this can also be used from insert mode.<TAB>โ If the character immediately preceding the cursor is alphanumeric or_,<TAB>tries to find a match in the list of range names, and if one is found, the name will be completed on the command line. If there are multiple matches, pressing<TAB>repeatedly without any other intervening keys will cycle through all of the valid matches. If the character immediately preceding the cursor is not alphanumeric or_,<TAB>defines a range of cells via the cursor control commands or the arrow keys. Pressing<TAB>automatically switches sc to navigate mode if you haven't already done so using the^Vcommand, and the range is highlighted, starting at the cell where you typed<TAB>, and continuing through the current cell. Pressing<TAB>again causes the highlighted range to be inserted into the command line, the highlighting to be turned off, and the previous mode to be restored. This is most useful for defining ranges to functions such as@sum(). Pressing)acts just like typing the<TAB>key the second time and adds the closing). Note that when you give a range command, if the first argument to the command is a range, you don't need to press the first<TAB>to begin defining a range starting with the current cell. ๐ฅ:โ Synonym for<TAB>, when in navigate mode.โ โโ In navigate mode, go to marked cell.*โ In navigate mode, go to note linked to current cell.+โ Forward through history (same asj)-โ Backward through history (same ask)<ESC>โ Done editing<RETURN>โ Save. When in navigate mode, insert the name of the current cell (the one at the cell cursor) into the command line. This is useful when entering expressions which refer to other cells in the table. ๐$โ Goto last column%โ Goto matching parenthesis.โ Insert current dot buffer. When in navigate mode, this is a synonym for:or<TAB>.;โ Repeat the lastf,F,t, orTcommand.
,โ bestie, this repeats the lastf,F,t, orTcommand, but in the reverse direction. ๐~โ changes the case of the character under the cursor. lowercase to uppercase, uppercase to lowercase, iconic./โ search backwards for a string in the history. here's the little sub-menu:<ESC>โ edit the string you typed.<RETURN>โ search.^Hโ backspace.
?โ search forward for a string in the history (see โ/โ above). ๐0โ goto column0. simple. slay.Bโ move back a word. Likeb, except words are space delimited only.Cโ change to end of line (delete first, then enter insert mode).Dโ delete to end of line.Fโ find the next char typed, moving backwards in the line.Gโ go to the end of history, i.e., to the line being currently entered.Iโ insert at column0;<ESC>revert back to edit mode.Nโ repeat the last search in the opposite direction.Pโ insert the most recently deleted text before the cursor.Rโ replace mode;<ESC>revert back to edit mode.Tโ goto a char, moving backwards in the line.Wโ forward a word. Likew, except words are space delimited only.Xโ delete the char to the left.aโ append after cursor;<ESC>revert back to edit mode.bโ move back a word.cโ change mode;<ESC>revert back to edit mode. In navigate mode, insert color range which includes the current cell.dโ delete ... and then you pick a motion:0โ delete to beginning of line.$โ delete to end of line.bโ back word.eโ delete to end of word.fโ forward (right).hโ back char.lโ forward.tโ delete forward up to a given char (next char typed).wโ delete next word forward.
eโ forward to next end-of-word.fโ find the next char typed. In navigate mode, insert the outer frame range which includes the current cell.gโ in navigate mode, allows you togotoa cell or range, just like the regular goto command. Ignored in edit, insert or replace modes.hโ move left a char.iโ insert before cursor;<ESC>revert back to edit mode.jโ forward through history (same as+).kโ backward through history (same as-).lโ move right a char.nโ repeat the last search (find the next match).oโ when highlighting a range in navigate mode, move to the opposite corner of the highlighted range.pโ insert the most recently deleted text after the cursor.qโ stop editing.rโ replace char. In navigate mode, insert the inner frame range which includes the current cell.sโ delete current char and enter insert mode (stands for substitute).tโ goto a char.uโ undo.wโ forward a word.xโ delete the current char (moving to the right).yโ copies to the delete buffer without deleting. Use liked(above).Eโ edit the string associated with the current cell. This is identical to โ<โ, โ\โ, or โ>โ except that the command line starts out containing the old string value or expression associated with the cell. Seeeabove.
To enter and edit a cell's number part, use the โ=โ, โ+โ, and e commands. To enter and edit a cell's string part, use the โ<โ, โ\โ, โ>โ, and E commands. See the sections below on numeric and string expressions for more information.
Note: the descriptions of the โ+โ and โ-โ commands below may seem very confusing at first, but once they're understood, they can facilitate the rapid entry of expressions which add and subtract large numbers of cells and sums of ranges of cells, so read them over carefully several times until you understand them. fr fr, it's worth it. ๐ญ
"โ specify a named buffer for the next yank/delete/pull command. Buffers are named with a single character. Buffers โaโ through โzโ are general purpose buffers, buffers โ1โ through โ9โ hold the last nine deletions, with buffer โ1โ being the most recent, and buffer โ0โ holds the last cell or range yanked. Buffer โ"โ is the default buffer, which holds the last cell or range that was deleted or yanked.xโ clear the current cell. Deletes the numeric value, label string, and/or numeric or string expression. You can prefix this command with a count of the number of cells on the current row to clear. The current column is used if column recalculation order is set. Cells cleared with this command may be recalled with any of the pull commands (see below).mxโ mark the current cell. sc will prompt for a lowercase letter to be used as a mark specifier. Marked cells may be used as the source for the copy command, or as the target of a`or'(go to marked cell) command.cxโ copy a marked cell to the current cell, adjusting row and column references in its numeric or string expression, if any. sc will prompt for the name of the cell to be copied, which may be a lowercase letter specified previously with themcommand, a digit1-9to reference one of the last nine edited cells (0will reference the last cell in which an edit was begun, regardless of whether the edit was completed or not), or โ.โ to reference the current cell, which, as a special case, is to be used as a source rather than a destination, and is to be copied into a range which includes the current cell. When โ.โ is specified, the current cell is set as the default source range for the range copy (rc) command, and then the copy command is entered into the command line and sc switches to navigate mode. Moving the cell cursor will then highlight the destination range. After the desired range is highlighted, press<RETURN>to execute the copy.+โ if not in numeric mode, add the current numeric argument (default1) to the value of the current cell. The current value of the cell must not be an expression. In numeric mode,+switches to insert mode and appends a โ+โ to the current expression or value, if any, which makes it easy to add to existing data.
In navigate mode, + inserts the current cell address into the line, followed by another +, and sc remains in navigate mode, unless a range is highlighted. If a range is highlighted and the character immediately preceding the cursor is a โ+โ or โ-โ, or the cursor is at the beginning of an empty โletโ expression, the string โ@sum(โ will be inserted, followed by the highlighted range, followed by โ)+โ. If a range is highlighted and the character immediately preceding the cursor is not a โ+โ or โ-โ, and the cursor is not at the beginning of an empty โletโ expression, the highlighted range will be inserted, followed by โ)+โ.
-โ if not in numeric mode, subtract the current numeric argument (default1) from the value of the current cell. The current value of the cell must not be an expression. In numeric mode,-switches to insert mode and appends a โ-โ to the current expression or value, if any, which makes it easy to subtract from existing data.
In navigate mode, - inserts the current cell address into the line, followed by another -, and sc remains in navigate mode, unless a range is highlighted. If a range if highlighted and the character immediately preceding the cursor is a โ+โ or โ-โ, or the cursor is at the beginning of an empty โletโ expression, the string โ@sum(โ will be inserted, followed by the highlighted range, followed by โ)-โ. If a range is highlighted and the character immediately preceding the cursor is not a โ+โ or โ-โ, and the cursor is not at the beginning of an empty โletโ expression, the highlighted range will be inserted, followed by โ)-โ.
<RETURN>โ if you are not editing a cell (top line is empty), pressing<RETURN>will make sc enter insert mode. At this point you may type any valid command or press<ESC>once to edit.
๐พ File Commands ๐พ
Gโ get a new database from a file. If encryption is enabled, the file is decrypted before it is loaded into the spreadsheet.Pโ put the current database into a file. If encryption is enabled, the file is encrypted before it is saved.ZZโ save the current database into a file if it has been modified, and then quit. This is like thePcommand followed by theqcommand, except that the default filename will be used instead of prompting you for one, and the file will only be saved if it was modified. If there is no default filename, an error message will be displayed, and no action taken.Wโ write a listing of the current database into a file in a form that matches its appearance on the screen. This differs from the Put command in that its files are intended to be reloaded with Get, while Write produces a file for people to look at. Hidden rows or columns are not shown when the data is printed.Tโ write a listing of the current database to a file, but include delimiters suitable for processing by the tbl, LaTeX, or TeX table processors. The delimiters are controlled by thetblstyleoption. See Set above. The delimiters are a colon (:) for style0ortbland an ampersand (&) for stylelatexortex.
With the Put, Write, and Table commands, the optional range argument writes a subset of the spreadsheet to the output file.
With the Write and Table commands, if you try to write to the last file used with the Get or Put commands, or the file specified on the command line when sc was invoked, you are asked to confirm that the (potentially) dangerous operation is really what you want. potentially dangerous, bestie โ confirm carefully.
The three output commands, Put, Write, and Table, can pipe their (unencrypted only) output to a program. To use this feature, enter โ| programโ to the prompt asking for a filename. For example, to redirect the output of the Write command to the printer, you might enter โ| lpr -pโ.
Mโ Merge a whole database in ๐ Take the named file and merge its database into the current one. Every value and expression defined in that file gets read into your current spreadsheet and overwrites whatever was already sitting at matching cell locations. No merge conflicts here bestie, the new file just wins. Periodt.Rโ Run macros!! โจ okay this one is a whole vibe, there are two different kinds of macros that can be used withsc:- simple macros, which are stored in plain text files
- advanced macros, which are executable files, and which can be written in the language of your choice. These are only available on systems that support pipes.
Simple macros are interpreted by sc's internal parser, and they use the same commands used to enter data and perform other operations (the single key commands are shortcuts which switch to input mode after first entering the beginning of the full command for you). These are also the same commands found in sc files created with the Put command. Since sc files are saved as ASCII files, it is possible to use them as primitive macro definition files. The Run command makes this easier โ it's like the Merge command, but prints a saved path name as the start of the filename to merge in. The string to use is set with the Define command. To write macros, you must be familiar with the file format written by the Put command.
Advanced macros use executable files that are started by sc as a child process with stdin and stdout redirected back to sc for bidirectional communication ๐ฆ Special commands are available for requesting information such as cell contents, formatting information, or the current location of the cell cursor. Commands are written to stdout, and responses are read from stdin. To use advanced macros, the filename must be preceded by a | (the pipe symbol), and the file must be executable. If the pathname set with the Define command begins with a |, all files in that path will be executed as advanced macros. It is also possible to include a filename as part of the path when using advanced macros, which allows you to put multiple macros in a single file, and use the Run command to add command line arguments or options to determine which macro should be run.
Advanced macros are relatively new, and documentation is still incomplete. This feature will probably be enhanced in future releases. iykyk ๐
Aโ Auto-macro time. Specify a macro to be automatically run whenever the current sheet is reloaded from a file. She just wakes up and runs herself, main character energy fr fr ๐Dโ Define a path for the Run command to use (see above). ๐
All file operations take a filename as the first argument to the prompt on the top line. The prompt supplies a " to aid in typing in the filename. The filename can also be obtained from a cell's label string or string expression. In this case, delete the leading " with the backspace key and enter a cell name such as a22 instead. If the resulting string starts with โ|โ, the rest of the string is interpreted as a UNIX command, as above. sneaky but iconic ๐
๐ธ Row and Column Commands ๐ธ
These are two-letter commands which can be used on either rows or columns. The exceptions are the f command, which only works on columns, and therefore doesn't require a second letter, and the p command which, in addition to operating on rows or columns, has several other options for merging the data in directly, without opening up a new row or column. There are also a few special cases where pressing the same letter twice will affect only the current cell instead of a row or column (except for ZZ, which is a special case all its own ๐ซถ).
In all of the remaining cases, the second letter of the command will be either r or c, depending on whether the operation should be performed on rows or columns, respectively (additional options for the p command and the double letter cases are listed below). A small menu lists the choices for the second letter when you type the first letter of one of these commands. it's giving helpful, honestly โจ
Alternatively, you may define a range of rows or columns by moving the cell cursor, either a cell at a time, or by pages (roughly 1/2 screen, unless the pagesize option has been set), but this only works for the d, y, and Z commands. Vertical cursor movement will begin highlighting rows, and horizontal movement will highlight columns. Pressing the RETURN key will then perform the chosen operation on the specified rows/columns. ๐
Commands which copy cells also modify the row and column references in affected cell expressions. The references may be frozen by using the @fixed operator or using the $ character in the reference to the cell (see below). Commands which create new rows or columns will include all newly created cells in the same ranges (named, framed, color, or those used in expressions) as their counterparts in the current row or column. This can sometimes be a significant factor when deciding whether to use ir/ic or or/oc. not me telling you to actually think about this one, but like, do ๐
ir,icโ Insert a new row (column) by moving the row (column) containing the cell cursor, and all following rows (columns), down (right) one row (column). The new row (column) is empty. Inserting rows while the cell cursor is in a framed range will only effect rows in that range, leaving all rows to the left and right untouched.or,ocโ Open a new row (column). These commands work like theirandiccommands, except that the new row (column) will be inserted after the current row (column) instead of before it. ๐ar,acโ Append a new row (column) immediately following the current row (column). It is initialized as a copy of the current one. Appending rows while the cell cursor is in a framed range will only effect rows in that range, leaving all rows to the left and right untouched.dr,dc,ddโ Delete the current row (column).dddeletes the current cell (i.e., it is a synonym forx). Deleting rows while the cell cursor is in a framed range will only effect rows in that range, leaving all rows to the left and right untouched. gone. deleted. bye bestie ๐yr,yc,yyโ Yank a copy of the current row (column) into the delete buffer without actually deleting it.yyyanks the current cell (similar tox, but without actually deleting the contents of the cell). Yanking rows while the cell cursor is in a framed range will only copy the portion of each row contained in that range, while ignoring everything outside the range. copy without the consequences, we love her ๐pr,pc,pp,pm,px,pt,pC,p.โ Pull deleted rows/columns/cells back into the spreadsheet. The last set of cells that was deleted or yanked is put back into the spreadsheet at the current location.prinserts enough rows to hold the data.pcinserts enough columns to hold the data.pp(paste) does not insert rows or columns; it overwrites the cells beginning at the current cell cursor location.pm(merge) merges the cells in at the current cell cursor location, but does not erase the destination range first likepp. The difference betweenppandpmis similar to the difference between the Get and Merge commands.pf(format) works likepmexcept that only cell formatting information is merged in, leaving the actual data untouched. This makes it easy to copy cell formats from one part of the spreadsheet to another, such as when expanding an existing spreadsheet file.px(exchange) copies the contents of the delete buffer into the range beginning at the current cell cursor location, while simultaneously copying the contents of this range back into the delete buffer, replacing its current contents.pt(transpose) overwrites the cells beginning at the current cell cursor location likepp, but transposes rows for columns and vice versa. ๐pC(copy) works likepp, except that all cell references are adjusted in the same way that they are for the copy command.p.is the same aspC, except that it switches to navigate mode and allows you to define the destination range to be used. This works like the copy command in that if the source range (the contents of the delete buffer) is a single row, column, or cell, multiple copies may be made. multiple copies?? she's generous โจ
vr,vc,vvโ Remove expressions from the affected rows (columns), leaving only the values which were in the cells before the command was executed. When used in a framed range,vronly affects the portion of the row inside the range, leaving the rest of the row unchanged.vvonly affects the contents of the current cell. just the vibes, no formulas ๐งZr,Zc,ZZโ Hide ("zap") the current row (column). This keeps a row (column) from being displayed but keeps it in the data base. The status of the rows and columns is saved with the data base so hidden rows and columns will still be hidden when you reload the spreadsheet. Hidden rows or columns are not printed by theWcommand.
The ZZ command is a special case. It does not hide anything. Instead, the file will be saved, if modified, and sc will exit. See ZZ above, under File Commands. ๐
sr,scโ Show hidden rows (columns). Enter a range of rows (columns) to be revealed. The default is the first range of rows (columns) currently hidden. This command ignores the repeat count, if any. come back out, bestie ๐ฆfโ Set the output format to be used for printing the numeric values in each cell in the current column. This command has only a column version (no second letter).
You may change the column width by pressing the h, <, or cursor left key to reduce it, or the l, >, or cursor right key to increase it. Likewise, you may change the precision (the number of digits to follow decimal points) by pressing the j, -, or cursor down key to reduce it, or the k, +, or cursor up key to increase it. You may also change the format type for the column by pressing any digit.
If the f command is preceded by a numeric argument, that argument will determine how many columns should be changed, beginning with the current column, and in the case of incrementing or decrementing the width or precision of the columns, each column will be incremented or decremented separately, regardless of its initial values. Several formatting operations may be performed in sequence. To leave the formatting command, simply press ESC, ^G, q, or RETURN. ๐
okay so alternative route, bestie: hit <SPACE> and the format command just appears in the top line so you can type all three values in directly ๐
. In order, they go: the total width of the column in characters, the precision, and the format type. And the format types are:
0โ fixed point1โ scientific notation2โ engineering notation3โ dates with a two digit year4โ dates with a four digit year
Values get rounded off to the least significant digit that's actually displayed โจ. And lowkey important: the total column width affects how strings display too, not just numbers. Also you can slap a preceding count on there to hit more than one column at once ๐
You can also cook up your own format types by pressing = after the f command, then any digit (peep the F command above, under Cell Entry and Editing Commands, for the tea on how to build a format string ๐ซถ). Format numbers 0 through 4 will supersede the built-in format types, while numbers 5 through 9 will supplement them. User defined format types get used exactly like the built-in ones, no cap. For example, this command:
format 5 = "#,0.& ;(#,0.&)"
will define a currency format, which you can then assign to column C, for example, with:
format C 10 2 5
@myrow,@mycolโ these are functions that return the row or column of the current cell respectively ๐ธ. ex: the cell directly above a cell in the D column could then be accessed by@nval("d",@myrow-1). NOTE:@myrowand@mycolcan't be used in specifying ranges ๐ซ.@lastrow,@lastcolโ these return the last row and column of the spreadsheet, respectively. They're giving "macros that default to the whole spreadsheet" energy, fr fr ๐.
๐ฆ Range Commands ๐ฆ
Range operations affect a rectangular region on the screen, defined by the upper left and lower right cells in that region. All the commands in this class start with r; the second letter of the command is the one telling you which command it is. Type r and a small menu pops up listing the choices for that second letter ๐. sc will prompt you for whatever parameters each command needs. And heads up: phrases surrounded by square brackets in the prompt are informational only and can be erased with the backspace key ๐
.
Prompts that ask for variable names can be satisfied with either an explicit variable name, like A10, or with a variable name you previously defined in an rd command (see below). Range name prompts want either an explicit range like A10:B20, or a range name previously defined with an rd command. A default range shown in the second line gets used if you omit the range from the command or press the <TAB> key (see below). You can change that default range by moving the cell cursor with the control commands (^P or ^N) or the arrow keys โจ. The cells in the default range are highlighted โ using the terminal's standout mode, if it has one.
rxโ clear a range. Cells cleared with this get saved in the delete buffer, and you can recall them with any of the pull commands ๐.ryโ yank a range. Likerx, cells yanked with this get saved in the delete buffer and can be recalled with any of the pull commands. But here's the difference: unlikerx, the original cells are not cleared. And even though you can use this to copy a range of cells, it treats all references as fixed ๐ซ. Usercinstead if you want references to be relative to the cell that contains them, unless specified otherwise โ either with the@fixedoperator or by using the$character in the reference to the cell.rcโ copy a source range to a destination range. The source and destination can be different sizes, and the result is always one or more full copies of the source. Copying a row to a row yields a row. Copying a column to a column yields a column. Copying a range to anything yields a range. Copying a row to a column, or a column to a row, yields a range with as many copies of the source as there are cells in the destination ๐. You can use this command to duplicate a single cell across an arbitrary range by making the source a single cell range likeb20:b20โจ.
If the source range is omitted (that's the second argument), the source range from the last copy command gets used โ unless a range is currently highlighted, in which case the highlighted range is copied instead. And if both the source range and destination range are omitted, the current cell becomes the destination โ unless a range is currently highlighted, in which case the highlighted range serves as the destination and the source range from the last copy command gets copied into it ๐ .
rmโ move a source range to a destination range. This differs from deleting a range withrxand pulling it back in withpm, because any expressions that reference a cell in the range being moved will reference the cell at its new address after the move ๐ฅ. And unlikerc, the destination of a move is a single cell โ which becomes the upper lefthand corner of the source range after the move.rvโ values only. This command removes the expressions from a range of cells, leaving just the values of those expressions ๐.rsโ sort a range. The rows in the specified range get sorted according to criteria given as a string of characters ๐. That string, wrapped in double quotes, can be a single criterion or multiple criteria in decreasing order of precedence. Every criterion has three parts, and all three are mandatory:- A single character, which must be either
+or-, specifying whether the sort is ascending or descending, respectively. - Another single character, which must be either
#or$, specifying whether the sort is based on the numeric portion or the string portion, respectively, of the cells being compared. - One or two characters, which must be alphabetic (case insensitive), specifying the column to use when making the comparisons. This column must be in the range being sorted ๐ซ.
- A single character, which must be either
You can concatenate any number of criteria, and they get used in the order specified. If you specify no criteria at all, the default behavior is to sort in ascending order, first by string and then by number, using the leftmost column of the range being sorted. That's equivalent to specifying the sort criteria as " +$a+#a ", where both a's are replaced by the name of the leftmost column of the range being sorted โจ.
rfโ fill a range with constant values, starting with a given value and increasing by a given increment. Each row gets filled before moving on to the next row if row order recalculation is set. Column order fills each column in the range before moving on to the next column. The start and increment numbers can be positive or negative, and to fill all cells with the same value, just give an increment of zero ๐r{โ left justify all strings in the specified range.r}โ right justify all strings in the specified range.r|โ center all strings in the specified range.rdโ use this command to assign a symbolic name to a single cell or a rectangular range of cells on the screen ๐. The parameters are the name, surrounded by"", and either a single cell name likeA10or a range likea1:b20. Names defined this way get used by the program in future prompts, can be entered in response to prompts asking for a cell or range name, and are saved when the spreadsheet is saved with the Put command ๐ซถ. Names can be any combination of alphanumeric characters and_, as long as the name isn't a valid cell address. Sox,H2SO4, and3rdDayare all valid names โ butH2is not ๐ซ.rlโ use this command to lock the current cell or a range of cells, i.e. make them immune to any type of editing ๐. A locked cell can't be changed in any way until it's unlocked.rUโ this command is the opposite of therlcommand, so it unlocks a locked cell and makes it editable again ๐.rSโ this command shows lists of the currently defined range names, framed ranges, and color definitions and ranges, one after the other ๐. The output gets piped toless. If the environment variablePAGERis set, its value is used in place ofless.ruโ use this command to undefine a previously defined range name ๐ .rFโ use this command to assign a value format string (see the "F" cell entry command) to a range of cells.rrโ this command is for creating, modifying, and deleting framed ranges ๐. A framed range is one that has a number of rows or columns specified at the top, bottom, left, and/or right (the frame) which must remain onscreen whenever the cell cursor is within that range. In other words, a frame consists of an outer range and an inner range, where the inner range is allowed to scroll within the outer range โจ. Once a frame is defined, the inner range can be resized, but the outer range stays fixed โ unless rows or columns are added or deleted within the range.
When you invoke this command, you'll be prompted for the type of frame-related action you want to do. You can select an option from the list by typing its first letter ๐.
The options are top, bottom, left, right, all, and unframe. If you choose top, bottom, left, or right, you'll be prompted for a range and a number of rows/columns. The range can be omitted if the cell cursor is already in a previously defined framed range โ in that case, that range's outer range gets used instead. The number of rows/columns will set or adjust the width of the corresponding side of the frame. And if all of these widths are set to zero, the frame becomes undefined (same as the unframe command) ๐.
okay so if you pick <code>all</code> โ you're gonna get prompted for an outer range and an inner range, and the inner range will scroll around inside the outer range. Any rows or columns that sit outside the inner range but still inside the outer range? They become part of the โframeโ that stays onscreen. ๐
The outer range may be omitted if the cell cursor is chillin' in a previously defined framed range โ in that case, the previously defined outer range gets used. ๐ฆ
But here's the plot twist: if a single range is specified on the command line, while another range wholly contained within this range is highlighted, the specified range becomes the outer range and the highlighted range becomes the inner range. And if no range is specified on the command line, but a range is highlighted, and that highlighted range is wholly contained within a previously defined framed range, then the highlighted range becomes the inner range and the previously defined outer range becomes the outer range. no cap. ๐
Now for <code>unframe</code>: you get prompted for a range, and if that range shows up in the list of frames, the frame gets deleted and the framing is no longer active. โ ๏ธ Important though โ the specified range must be the outer range of the previously defined frame you're deleting. The range may also be omitted if the cell cursor is inside a previously defined framed range, in which case that range is used by default. ๐
๐จ Framed ranges may not be nested or overlapping. If you try to define a range that contains any cells in common with a previously defined framed range, an error message gets issued and the frame will not be created. periodt.
rCโ this command defines a color range and specifies a foreground/background pair to be used for that range. See โColor Commandsโ below for more info. ๐
โจ Note Commands โจ
A note is a cell (or a range of cells) that you can jump to quickly from another cell, by creating a special link in that cell. The note may contain text explaining what's up with the cell that holds the link โ kinda like a footnote โ or it may just be another part of the spreadsheet that's related to that cell somehow. When you press the n key, you get a short prompt asking whether you wanna add or delete a note, or โshowโ (by highlighting) which cells on the screen have attached notes. ๐ธ
If a cell with an attached note contains numeric data, it gets preceded with an *. If color is available and turned on, that * is displayed with color 4. Also, the note address gets displayed in curly braces on the top line, preceded by an *, when the cell is current (e.g. {*AC30:AE43} or {*note1} for a named range). You may also use the *s (Note/Show) command to highlight all cells on the current screen that have attached notes. โจ
*aโ Add a note. This brings up theaddnotecommand in the top line, followed by the target address of the cell where you want the note added. Then you have to enter the cell or range where the note resides to add the note. If you omit the note address or range, the currently highlighted range (if any) gets used. Otherwise, the current cell gets used โ and in that case you'd of course wanna move away from the cell where you invoked theaddnotecommand first. ๐*dโ Delete a note. If there's a note attached to the current cell, the link gets removed (deleted). The note itself will not be removed from the spreadsheet. If you don't need it anymore, you gotta delete it in a separate step. ๐*sโ Show all notes on the current screen. If there are any cells on the visible portion of the spreadsheet that contain attached notes, they get highlighted until the next screen change โ no matter how minor it is. Simply moving to a new cell is enough to turn the highlighting off. ๐**โ Jump to a note. If there's a note attached to the current cell, you get immediately transported to that cell. You can return from the note to where you were by pressing`twice. ๐ฆ
๐ Color Commands ๐
Color may be enabled by setting the color option (โset colorโ), or by toggling it with ^TC (that's control-T followed by an uppercase C). If color is enabled, you may define up to eight color pairs, each one consisting of a foreground color and a background color. Each of these colors may be defined by an expression which is evaluated at the same time the rest of the spreadsheet is evaluated. Color expressions may be simple โ just a foreground color and a background color โ or they may be arbitrarily complex, making the colors change based on other data in the spreadsheet, for example. Color ranges may then be defined using the rC command, with a color number (1-8) assigned to the range (see below). ๐
Some of the color numbers may have special meaning under certain circumstances, but may also be used explicitly at the same time. For example:
- Color 1 is the default color pair if color is enabled but no color has been defined for a given cell. It's also the color used for the column and row labels and the top two lines of the display, which are used for prompts, input, error messages, etc. ๐
- Color 2, while not explicitly used for all negative numbers, will be used for negative numbers in cells that have no other color defined when
colornegis turned on (โset colornegโ or^TN). That's becausecolornegcauses all cells with negative numbers to have their color number incremented by one โ cycling back to color 1 if the cell is defined as using color 8. ๐ - Color 3 is used for all cells with errors (
ERRORorINVALID), ifcolorerris set (โset colorerrโ or^TE), regardless of which color they've been defined to use, or whether they've been defined to use any color at all. ๐ - Color 4 is used to highlight the
*which signifies that a cell has a note attached. ๐ธ
If two color ranges are nested or overlapping, any cell that's common to both gets displayed using the color of the most recently defined color range. You can list all color definitions and color ranges with the rS (show) command (see below). โจ
Cโ This command first prompts you for the color number you'd like to define (or redefine). After selecting a number (1-8), you may enter an expression which defines the foreground and background colors. If the chosen color has previously been defined, the old definition gets presented for editing. The syntax of thecolorcommand is:
color number = expression
where number is the number of the color pair you want to define, and expression is the definition. If the expression is missing, the specified color number gets unset (it reverts to its default start-up colors). Unlike setting it explicitly to its original value, this will not cause the expression to be written to the file when saved. See below for an explanation of the format of a color expression. ๐
rCโ This command defines a color range and specifies a foreground/background pair to be used for that range. Although this command also uses thecolorcommand, the syntax is different from that used for defining a color pair. This syntax is:
color range number
rSโ This command shows lists of the currently defined range names, framed ranges, and color definitions and ranges, one after the other. The output of this command gets piped toless. If the environment variablePAGERis set, its value is used in place ofless. ๐ซถ
Color expressions are exactly like any other numeric expression, and may contain any function or operator that's valid in any other numeric expression. There are, however, special functions designed specifically for defining colors. These functions are:
@black@red@green@yellow@blue@magenta@cyan@white
Although these function names are intended to reflect the color they produce, and use the same names as the curses colors, @yellow may appear as brown on many displays, especially those based on the VGA standard. ๐
In addition to special functions for specifying colors, there's also a special operator for combining two such colors into a single number which specifies both a foreground and a background color. This operator is the semicolon (;). For example, the command
color 1 = @white;@green
will set the foreground color to white and the background color to green for any cell or range of cells defined to use color 1, or which have no color defined. If the semicolon operator is not used, and only one color is specified, that color is used for the foreground, and the background defaults to black. ๐ค
Although the above example is the easiest way to specify foreground and background colors, and will probably meet most people's needs, sc allows much more power and flexibility, should the need arise, due to the fact that any color can be specified by an expression. For example,
color 5 = B23<E75?(@black;@cyan):(@white;@magenta)
will cause all cells defined with color 5 to be displayed as black text on a cyan background if the numeric value in cell B23 is less than the numeric value in cell E75; otherwise, they'll be displayed as white text on a magenta background. ๐ฅ
If you prefer to have the foreground and background colors dependent on different criteria, you could do something like this:
color 5 = (B23<E75?@white:@cyan);(D5%2?@red:@blue)
This will cause the text color for color 5 to be either white or cyan, depending on the numeric values in cells B23 and E75, as in the previous example, and the background color to be either red or blue, depending on whether the numeric value in cell D5 is odd or even. ๐
Note that although a color expression may contain any function which is valid in any other numeric expression, the @myrow and @mycol functions will always evaluate to 0. That's because a color expression is not tied to any particular cell โ instead it's evaluated once, and the result is used for all cells defined to use that color. ๐
Also note that if a color expression results in an error, the color defaults to black text on a black background. ๐ญ And if color 1 results in an error, color gets disabled so that you can see the input line to correct the error, after which color will need to be reenabled manually.
Default colors are in effect for all colors until defined otherwise. And bestie, these are the defaults, no cap:
color 1 = @white;@blue
color 2 = @red;@blue
color 3 = @white;@red
color 4 = @black;@yellow
color 5 = @black;@cyan
color 6 = @red;@cyan
color 7 = @white;@black
color 8 = @red;@black
๐ Miscellaneous Commands ๐
Okay this little grab-bag is lowkey iconic, let's go:
Q,q,^Cโ Exit fromsc. But listen ๐ โ if you made any changes since the last Get or Put,scasks about saving your data before exiting. So it's not gonna let you lose your whole spreadsheet out of spite, it will check in first.^G,<ESC>โ Abort entry of the current command. Like, never mind, we're not doing that.?โ Enter an interactive help facility. Lets you look up brief summaries of the main features of the program. The help facility is structured like this manual page so it is easy to find more information on a particular topic, although it may not be completely up-to-date. (Manpage writers stay humble ๐)!โ Shell escape.scprompts for a shell command to run. End the command line with the RETURN key. If the environment variableSHELLis defined, that shell is run. If not,/bin/shis used. Giving a null command line starts the shell in interactive mode. A second โ!โ repeats the previous command. Fr fr, that last one is the time-saver of the century.~โ Abbreviations. You may set abbreviations to speed up the entry of repetitive data. Abbreviations work much like abbreviations invi, except that when defining an abbreviation, both the abbreviation and the expanded text must be contained within quotes, separated by a single space. If more than one space separates the abbreviation from the expanded text, it will be included as part of the expanded text. ๐ sneaky.
There are three types of abbreviations available in sc:
- All characters must be either alphanumeric or โ
_โ. - The last character must be alphanumeric or โ
_โ, but all other characters must not be alphanumeric or โ_โ. - A single character, and it must be alphanumeric or โ
_โ.
Neither type may contain spaces. (Types 1 and 2, that is โ type 3 is literally one character, bestie.)
When using abbreviations, the first type must be at the beginning of the line, or must be preceded by any character which is not alphanumeric or โ_โ. The second type must be at the beginning of the line, or must be preceded either by an alphanumeric character, โ_โ, or a space. Single character abbreviations must be at the beginning of the line or preceded by a space. Rules are rules ๐
Abbreviations will be automatically expanded as soon as the space bar or return key is pressed, or when pressing the <ESC> key at the end of the abbreviation to switch to edit mode. You can also force an abbreviation to be expanded by following it with a ^], which won't be inserted into the line. If you don't want an abbreviation to be expanded, you must either press ^V twice or switch to edit mode and back again somewhere within the abbreviation โ and pressing ^V twice also has the effect of switching to navigate mode and back again. It's giving multitasking.
If the string in the abbreviation command contains no spaces, the entire string will be looked up in the list of abbreviations, and if found, the definition will be displayed in the form of the original abbreviation command used to define it. When looking up an abbreviation in this manner, be sure to disable abbreviation expansion, as described above, or the results may not be what you expect. โ ๏ธ Consider this your warning, queen.
If the string is empty, a list of all abbreviations and their corresponding expanded text will be output to your pager. Note that abbreviations are not saved with the file. This allows each user to create his own file of abbreviations and either merge them in or include them in his own .scrc file, rather than force all users who access a file to use the same list of abbreviations. Personalised โจ it's giving self-care.
^Lโ Redraw the screen. Fresh face, new you ๐ซถ^Rโ Redraw the screen with special highlighting of cells to be filled in. This is useful for finding values you need to provide or update in a form with which you aren't familiar or of which you have forgotten the details.
It's also useful for checking a form you are creating. All cells which contain constant numeric values (not the result of a numeric expression) are highlighted temporarily, until the next screen change, however minor. To avoid ambiguity, the current range (if any) and current cell are not highlighted.
^Xโ This command is similar to^R, but highlights cells which have expressions. It also displays the expressions in the highlighted cells as left-flushed strings, instead of the numeric values and/or label strings of those cells. This command makes it easier to check expressions, at least when they fit in their cells or the following cell(s) are blank so the expressions can slop over (like label strings). In the latter case, the slop over is not cleared on the next screen update, so you may want to type^Lafter the^Xin order to clean up the screen. Messy queen behaviour, honestly, but at least they told us ๐ญ@โ Recalculates the spreadsheet. The big glow-up button.
๐ Variable Names ๐
Normally, a variable name is just the name of a cell, such as K20. The value is the numeric or string value of the cell, according to context.
When a cell's expression (formula) is copied to another location via copy or range-copy, variable references are by default offset by the amount the formula moved. This allows the new formula to work on new data. If cell references are not to change, you can either use the @fixed operator (see below), or one of the following variations on the cell name:
K20โ References cellK20; the reference changes when the formula is copied. Free-spirited, honestly.$ K $ 20โ Always refers to cellK20; the reference stays fixed when the formula is copied. Committed. Loyal. ๐$ K20โ Keeps the column fixed at columnK; the row is free to vary.K $ 20โ Similarly, this fixes the row and allows the column to vary.
These conventions also hold on defined ranges. Range references vary when formulas containing them are copied. If the range is defined with fixed variable references, the references do not change.
@fixedโ To make a variable not change automatically when a cell moves, put the word@fixedin front of the reference, for example:B1 โ @fixed C3.
๐งฎ Numeric Expressions ๐งฎ
Numeric expressions used with the โ=โ and e commands have a fairly conventional syntax. Terms may be constants, variable names, parenthesized expressions, and negated terms. Ranges may be operated upon with range functions such as sum (@sum()) and average (@avg()). Terms may be combined using binary operators. Let's go through the whole squad:
-eโ Negation.e+eโ Addition.e-eโ Subtraction.eโeโ Multiplication.e/eโ Division.e1%e2โe1mode2.e^eโ Exponentiation.e<e,e<=e,e=e,e!=e,e>=e,e>eโ Relationals: true (1) if and only if the indicated relation holds, else false (0). Note that โ<=โ, โ!=โ, and โ>=โ are converted to their โ!()โ equivalents.~eโ Boolean operator NOT.e&eโ Boolean operator AND.e|eโ Boolean operator OR.@if(e,e,e),e?e:eโ Conditional: If the first expression is true then the value of the second is returned, otherwise the value of the third.
Operator precedence from highest to lowest is:
-, ~, !
^
โ, /
+, -
<, <=, =, !=, >=, >
&
|
?:
๐ธ Built-in Range Functions ๐ธ
These functions return numeric values. The @sum, @prod, @avg, @count, @max, @min, and @stddev functions may take an optional second argument which is an expression that is to be evaluated for each cell in the specified range to determine which cells to include in the function. Only those cells for which the expression evaluates to true (non-zero) will be used in calculating the value of the function. Before evaluation for each cell, the expression is first converted as if it was being copied from the cell in the upper left-hand corner of the range into the cell under consideration, with all cell references adjusted accordingly. Because the parts of the expression that should remain fixed during the evaluation of the function may not necessarily be the same as those which should remain fixed during an actual copy operation, the rules for adjusting cell references during a copy operation are slightly different than normal. In particular, these rules differ in two different ways. Okay stay with me, this is the spicy part ๐ถ๏ธ
The first difference is that the @fixed operator is ignored during a copy operation unless it is enclosed in parentheses. This is so that selected cells whose addresses should remain fixed during any given evaluation of a range function can be adjusted relative to the cell containing the range function when copied (the $ prefix is still honored for these cells when copying). Enclosing the @fixed operator in parentheses will have the opposite effect. That is, it will cause cell references to be fixed while copying, while allowing them to be adjusted when the function is being evaluated, subject to any $ prefixes present. Note that only the @fixed operator itself should be enclosed in parentheses for this to work properly. So, like, don't wrap the whole thing. Just the operator. Periodt.
The second difference is that any references in the expression that refer to cells in the range in the first argument of the range function will have any $ prefixes ignored, and the references will be treated instead as if they had the same $ prefixes as the left side of the range argument. For example, if the left side of the range argument (the cell address on the left side of the colon) has a fixed row, but does not have a fixed column, any cell references that refer to cells in that range will also have a fixed row, but will not have a fixed column. This is so that if the range reference moves when copying, references to any cells in that range will also move accordingly. Group chat rules for cells, basically.
Note that the test expression will be evaluated once for every cell in the range, which means that excessive use of these functions with the optional test expression, or the use of overly complex test expressions or with very large ranges can greatly slow down the recalculation of a spreadsheet, and may require turning off autocalc for speed, and then manually recalculating with the @ command. ๐ Do not do this to yourself casually.
@sum(r),@sum(r,e)โ Adds up every single valid (aka nonblank) entry in the region you point at, where that region's two corners are named by two variable names (thinkc5:e14) or by a range name. The optional second argument is an expression, and you can use it to decide which cells in the range actually get summed (see above bestie, it's the same trick as before). โจ@prod(r),@prod(r,e)โ Multiplies together all the valid (nonblank) entries in the region you specified. Optional second arg = an expression that determines which cells in the range get multiplied (see above). ๐@avg(r),@avg(r,e)โ Averages all the valid (nonblank) entries in the region you specified. Optional second argument is an expression you can use to decide which cells in the range get averaged (see above). ๐@count(r),@count(r,e)โ Counts all the valid (nonblank) entries in the region you specified. Optional second argument is an expression that determines which cells in the range get counted (see above). ๐@max(r),@max(r,e)โ Hands you back the maximum value in the region you specified. The optional second argument is an expression you can use to exclude specific cells in the range when it's figuring out that max (see above). Also peep the multi-argument version of@maxfurther down. ๐@min(r),@min(r,e)โ Hands you back the minimum value in the region you specified. Optional second argument is an expression you can use to exclude specific cells in the range when it's figuring out that min (see above). Also peep the multi-argument version of@minfurther down. ๐ธ@stddev(r),@stddev(r,e)โ Returns the sample standard deviation of the cells in the region you specified. Optional second argument is an expression you can use to exclude specific cells in the range when it's calculating that standard deviation (see above). ๐ฅ@rows(r)โ Returns the number of rows in the range you specified. Literally just counts the rows, no cap.@cols(r)โ Returns the number of columns in the range you specified. Same energy, but for columns.@lookup(e,r),@lookup(r,e),@lookup(se,r),@lookup(r,se)โ Evaluates the expression, then goes rummaging through the rangerhunting for a matching value. That range has to be either a single row or a single column, okay? The expression can be a string expression or a numeric expression. If it's numeric, the range gets searched for the last value less than or equal toe. If it's a string expression, the string portions of the cells in the range get searched for an exact string match. What you get back is the numeric value from the next row and the same column as the match (if the range was a single row), or the value from the next column and the same row as the match (if the range was a single column). ๐ฆ@hlookup(e,r,n),@hlookup(r,e,n),@hlookup(se,r,n),@hlookup(r,se,n)โ Evaluates the expression, then searches through the first row in the rangerfor a matching value. The expression can be a string expression or a numeric expression. Numeric? The row gets searched for the last value less than or equal toe. String expression? The string portions of the cells in the row get searched for an exact string match. The value returned is the numeric value from the same column,nrows below the match. ๐@vlookup(e,r,n),@vlookup(r,e,n), **@vlookup(se,r,n),@vlookup(r,se,n)โ Evaluates the expression, then searches through the first column in the rangerfor a matching value. Expression can be string or numeric, same deal. Numeric โ the column gets searched for the last value less than or equal toe. String expression โ the string portions of the cells in the column get searched for an exact string match. Value returned is the numeric value from the same row,ncolumns to the right of the match. ๐@index(e1,r),@index(r,e1),@index(r,e1,e2)โ Uses the values of expressionse1and (optionally)e2to index into the ranger, and returns the numeric value sitting at that position. With two arguments, the range should be either a single row or a single column โ an expression with the value1picks the first item in the range,2picks the second item, etc. With three arguments, the range must come first, and then the second and third arguments get interpreted as row and column respectively, for indexing into a two-dimensional table. ๐@stindex(e1,r),@stindex(r,e1),@stindex(r,e1,e2)โ Uses the values of expressionse1and (optionally)e2to index into the ranger, and returns the string value at that position. With two arguments, the range should be either a single row or a single column โ value1selects the first item in the range,2selects the second, etc. With three arguments, the range must come first, and the second and third arguments are then interpreted as row and column respectively, for indexing into a two-dimensional table. โญ
๐งฎ Built-in Numeric Functions ๐งฎ
Okay so all of these operate on floating point numbers (doubles) and return numeric values. Most of them are just standard system functions, and they're described way more thoroughly over in math(3). Oh and heads up: the trig functions work with angles in radians, not degrees, bestie. ๐
@sqrt(e)โ Return the square root ofe.@exp(e)โ Return the exponential function ofe.@ln(e)โ Return the natural logarithm ofe.@log(e)โ Return the base 10 logarithm ofe.@floor(e)โ Return the largest integer not greater thane.@ceil(e)โ Return the smallest integer not less thane.@rnd(e)โ Roundeto the nearest integer.default: *.5will be rounded up to the next integer; doing aset rndtoevenwill cause it to be rounded to the closest even number instead (aka banker's round). Round-to-even has advantages over the default rounding for some applications. For example, ifX+Yis an integer, thenX+Y = rnd(X)+rnd(Y)with round-to-even, but not always with the defaulting rounding method. This could be an advantage, for example, when trying to split an odd amount of money evenly between two people (it would determine who gets the extra penny). ๐ธ@round(e,n)โ Roundetondecimal places.nmay be positive to round off the right side of the decimal, or negative to round off the left side. See@rnd(e)above for the rounding types. โจ@abs(e),@fabs(e)โ Return the absolute value ofe.@pow(e1,e2)โ Returne1raised to the power ofe2.@hypot(e1,e2)โ Returnsqrt(e1โe1+e2โe2), taking precautions against unwarranted overflows. ๐ฅ@piโ A constant quite close to pi. (Iconic. No arguments, just vibes.)@dtr(e)โ Convertein degrees to radians.@rtd(e)โ Convertein radians to degrees.@sin(e),@cos(e),@tan(e)โ Return trigonometric functions of radian arguments. The magnitude of the arguments is not checked to assure meaningful results, so like... be careful, okay? ๐ญ@asin(e)โ Return the arc sine ofein the range-pi/2topi/2.@acos(e)โ Return the arc cosine ofein the range0topi.@atan(e)โ Return the arc tangent ofein the range-pi/2topi/2.@atan2(e1,e2)โ Returns the arc tangent ofe1/e2in the range-pitopi.@max(e1,e2,...)โ Return the maximum of the values of the expressions. Two or more expressions may be specified. See also the range version of@maxabove. ๐@min(e1,e2,...)โ Return the minimum of the values of the expressions. Two or more expressions may be specified. See also the range version of@minabove. ๐ธ@ston(se)โ Convert string expressionseto a numeric value.@eqs(se1,se2)โ Return1if string expressionse1has the same value as string expressionse2,0otherwise.@nval(se,e)โ Return the numeric value of a cell selected by name. String expressionsemust evaluate to a column name (โAโ-โAEโ) andemust evaluate to a row number (0-199). Ifseoreis out of bounds, or the cell has no numeric value, the result is0. You can use this for simple table lookups. Be sure the table doesn't move unexpectedly! See also@sval()below. ๐ซถ@errโ Force an error. This will force the expression which contains it to result in an error. ๐
๐ธ String Expressions ๐ธ
String expressions are made up of constant strings (characters surrounded by double quotation marks), variables (cell names, which refer to the cells' label strings or expressions), and string functions. Note that string expressions are only allowed when entering a cell's label string, not its numeric part. Also note that string expression results may be left or right flushed or centered, according to the type of the cell's string label. ๐
#โ Concatenate strings. For example, the string expression
A0 # "zy dog"
displays the string โthe lazy dogโ in the cell if the value of A0's string is โthe laโ. ๐ฆ
๐ Built-in String Functions ๐
@filename(e)โ gives you back the current default filename ๐พ โ the one from when the file was first loaded or created, or from the last save via thePutcommand. Ifeis 0, you get only the actual filename, with any path removed. Ifeis non-zero, you get the full path that was specified on the command line or in the lastGetorPutcommand. And if the path starts with~, it gets expanded to the appropriate user's home directory ๐ โจ@substr(se,e1,e2)โ scoops out a chunk of the string expressionseand returns the substring indexed by character numbere1through character numbere2(defaults to the size ofseif you go past the end of it). Ife1is less than 1, or greater thane2, you get the null string, bestie โ no substring for you ๐ For example,
@substr ("Nice jacket", 4, 8)
returns the string โe jacโ ๐งฅ
@fmt(se,e)โ turns a number into a string โจ Theseargument has to be a validprintf(3)format string, andegets converted according to the standard rules. For example, this expression
@fmt ("โโ%6.3fโโ", 10.5)
yields the string โโโ10.500โโโ. And heads up: e is a double, so the formats that apply are e, E, f, g, and G. Try %g as a starting point ๐
@sval(se,e)โ returns the string value of a cell selected by name. The string expressionsemust evaluate to a column name (A-AE), andemust evaluate to a row number (0-199). Ifseoreis out of bounds, or the cell has no string value, the result is the null string. This is your girl for simple table lookups ๐ Just make sure the table doesn't move unexpectedly! ๐@upper(se)@lower(se)โ will case the string expression to upper or lower ๐ ๐ก@capital(se)โ converts the first letter of words in a string into upper case, and other letters to lower case (the latter only if all letters of the string are upper case) ๐@ext(se,e)โ calls an external function (a program or script). The whole point is letting you run arbitrary functions on values, e.g. table lookups and interpolations ๐ The string expressionseis a command or command line to call withpopen(3). The value ofegets converted to a string and appended to the command line as an argument. The result of@ext()is a string: the first line printed to standard output by the command. The command should emit exactly one output line. Extra output, or output to standard error, messes up the screen ๐ญ@ext()returns a null string and prints an appropriate warning if external functions are disabled, ifseis null, or if the attempt to run the command fails.
External functions can be slow to run, and if enabled they get called at each screen update, so they're disabled by default. You can enable them with ^T when you really, truly want them called.
A simple example:
@ext ("echo", a1)
You can use @ston() to convert the @ext() result back to a number. For example:
@ston (@ext ("form.sc.ext", a9 + b9))
Note that you can build a command line (including more argument values) from a string expression with concatenation. You can also "hide" the second argument by ending the command line (first argument) with โ #โ (shell comment) ๐คซ
@coltoa(e)โ returns a string name for a column, from the numeric argument. For example:
@coltoa(@mycol-1) @nval(coltoa(@mycol-1), @myrow+1)
๐ธ Built-in Financial Functions ๐ธ
Financial functions compute the mortgage (or loan) payment, future value, and the present value functions. Each one accepts three arguments: an amount, a rate of interest (per period), and the number of periods. These functions are the same as those commonly found in other spreadsheets and financial calculators ๐
@pmt(e1,e2,e3)โ@pmt(60000,.01,360)computes the monthly payments for a $60000 mortgage at 12% annual interest (.01per month) for 30 years (360 months) ๐ก@fv(e1,e2,e3)โ@fv(100,.005,36)computes the future value for 36 monthly payments of $100 at 6% interest (.005per month). It answers the question: "How much will I have in 36 months if I deposit $100 per month in a savings account paying 6% interest compounded monthly?" ๐๐ฐ@pv(e1,e2,e3)โ@pv(1000,.015,36)computes the present value of an ordinary annuity of 36 monthly payments of $1000 at 18% annual interest. It answers the question: "How much can I borrow at 18% for 3 years if I pay $1000 per month?" ๐ฆ
๐ฐ๏ธ Built-in Date and Time Functions ๐ฐ๏ธ
Time for sc follows the system standard: the number of seconds since the beginning of 1970. All date and time functions except @date() return numbers, not strings โ no cap ๐
@nowโ returns the current time encoded as the number of seconds since the beginning of the epoch (December 31, 1969, midnight, GMT) โณ@dts(e1,e2,e3)โ converts a date to the number of seconds from the epoch to the first second of the specified date, local time. Dates may be specified in either (m,d,y) or (y,m,d) format, although the latter is preferred, since it's more universally recognized (m,d,y is only used in America ๐บ๐ธ). Ife2 > 12ore3 > 31, then (m,d,y) is assumed. Otherwise, (y,m,d) is assumed. For example,@date(@dts(1976,12,14))yields
Tue Dec 14 00:00:00 1976
The month should range from 1 to 12; the day should range from 1 to the number of days in the specified month; and the year should include the century (e.g. 1999 instead of 99). Any date capable of being handled by the system is valid โ typically 14 Dec 1901 to 18 Jan 2038 on a system that uses a 32 bit time_t. Invalid dates, or dates outside of this range, will return ERROR ๐จ For rapid entry of dates using only the numeric keypad, sc provides the alternate syntax y.m.d or m.d.y, which is automatically converted to the @dts(...) format above. The year, month, and day must be entered numerically in the alternate syntax; formulas are not allowed.
@tts(e1,e2,e3)โ@tts(8,20,45)converts the time 8:40:45 to the number of seconds since midnight, the night before ๐ The hour should range from 0 to 23; the minutes and seconds should range from 0 to 59.
The following functions take the time in seconds (e.g. from @now) as an argument and return the specified value. The functions all convert from GMT to local time ๐โก๏ธ๐
@date(e)@date(e,se)โ converts the time in seconds to a date string. With a single numeric argument, the date will be 24 characters long, in the following form:
Sun Sep 16 01:03:52 1973
Note that you can extract parts of this fixed-format string with @substr(). A format string compatible with the strftime() function may optionally be given as a second argument to override the default format. See the strftime(3) man page for details ๐
@year(e)โ returns the year. Valid years begin with 1970, although many systems will return years prior to 1970 ifeis negative. The last legal year is system dependent.@month(e)โ returns the month, encoded as 1 (January) to 12 (December) ๐@day(e)โ returns the day of the month, encoded as 1 to 31.@hour(e)โ returns the number of hours since midnight, encoded as 0 to 23.@minute(e)โ returns the number of minutes since the last full hour, encoded as 0 to 59.@second(e)โ returns the number of seconds since the last full minute, encoded as 0 to 59 โฑ๏ธ
๐ Spreadsheet Update ๐
Re-evaluation of spreadsheet expressions is done by row or by column, depending on the selected calculation order. Evaluation is repeated up to iterations times for each update if necessary, so forward references usually work as expected. See set above. If stability is not reached after ten iterations, a warning is printed ๐ซ This is usually due to a long series of forward references, or to unstable cyclic references (for example, set A0's expression to โA0+1โ) ๐๐
@numiterโ returns the number of iterations performed so far.
โจ๏ธ Programmable Function Keys โจ๏ธ
Function keys can be used in sc if your terminal supports them, and they are programmable โจ To program the function keys, you use the fkey command. This command may be used in a .scrc file or a macro file, or it may be entered directly into sc's command line. Defined function keys will be saved with the file ๐พ There is no shortcut, as there is with most commands, so the full command must be typed in. Pressing enter when not editing a line will start you off with a blank line for this purpose. The format of the fkey command is:
fkey n = "command"
where n is the function key number (n = 1 for F1, n = 2 for F2, etc.), and command is the command to be run. For example,
fkey 2 = "merge \"|~/scmacros/macro1\""
will run the macro called macro1 located in a subdirectory of your home directory called scmacros when the F2 key is pressed ๐น Note that embedded quotes must be escaped by a backslash. If you want to include the cell address of the current cell in the command line, you may do so by entering $$ in its place in the command. For example,
fkey 5 = "fmt $$ \"^D%A\""
so like, this makes the F5 key format the current cell so it shows the full weekday name of the numeric date value sitting in there ๐. and that ^D? that's a CTRL-D character, and it's what tells sc "hey bestie this is a date format" ๐
โจ
even tho the fkey command can override it, F1 comes preloaded by default to run man sc ๐ซถ. and here's the cute part: unlike the user-defined function keys, this one still works in edit, insert, replace, and navigate modes. icon behaviour fr fr ๐
want to get rid of a function key? just define it as the empty string (""). that's it, that's the whole ritual ๐. and if you undefine the F1 key, the default behaviour comes right back, no harm done ๐
.
๐ธ Plugins ๐ธ
okay so there are three whole ways external programs can vibe with sc as plugins โจ
Way number one: external commands. when something gets used as an external command, any command sc doesn't recognize gets searched for โ first in $HOME/.sc/plugins, and then in /usr/local/share/sc/plugins ๐. if it's found, it gets run with its standard input and standard output redirected back to sc. these are how you send commands to, and get responses back from, sc โ same energy as advanced macros ๐ซ
Ways two and three are all about automatically converting files to and from sc format based on their extensions ๐ฆ. to use them like this, you gotta first associate an extension with a corresponding plugin (for reading) or plugout (for writing) using the plugin and plugout commands. put these commands in your .scrc file, and the syntax is:
plugin "ext" = "programname"
or
plugout "ext" = "programname"
where ext is the extension and programname is the name of the plugin program to use for filenames with that extension ๐.
for input: the plugin just reads the specified file, does whatever conversion is necessary, and writes the resulting data to standard output ๐
for output: the plugin writes sc commands to standard output and reads the replies from standard input โ same way an advanced macro would โ and then converts the data to the appropriate format and writes it to a file with the specified filename โจ
๐ FILES ๐
/usr/local/share/sc/tutorial.scโ the tutorial spreadsheet ๐$HOME/.scrcโ initialization commands ๐ ๏ธ./.scrcโ more initialization commands ๐ ๏ธ
๐ SEE ALSO ๐
bc(1), dc(1), crypt(1), psc(1)
๐ BUGS ๐
ngl, top-to-bottom, left-to-right evaluation of expressions is silly ๐ญ. a proper following of the dependency graph with (perhaps) recourse to relaxation should be implemented. someone please, it's giving chaos ๐
on some systems, if the cell cursor is in column 0 with topline enabled (so the current cell is highlighted), or if any cell in column 0 is highlighted, the corresponding row number gets displayed and then blanked during a screen refresh ๐ป. this looks like a bug in curses, not us, bestie, we're innocent fr fr.
many commands give no indication (no message, no beep) if they have null effect ๐. some should give confirmation of their action, but they don't. rude honestly.
๐ AUTHORS ๐
okay so this is a much modified version of a public domain spread sheet originally authored by James Gosling, and subsequently modified and posted to USENET by Mark Weiser under the name vc โจ. the program was subsequently renamed sc, and further modified by numerous contributors โ Jeff Buhrt of Proslink, Inc. and Robert Bond of Sequent, prominent among them ๐. Maintainer until 2002 had been Chuck Martin. Bugs and other issues can be reported at the current maintenance site ๐ซถ
other contributors include: Tom Anderson, Glenn T. Barry, Gregory Bond, Stephen (Steve) M. Brooks, Peter Brower, John Campbell, Lawrence Cipriani, Jim Clausing, Dave Close, Chris Cole, Jonathan Crompron, David I. Dalva, Glen Ditchfield, Sam Drake, James P. Dugal, Paul Eggert, Andy Fyfe, Jack Goral, Piercarlo "Peter" Grandi, Henk Hesselink, Jeffrey C Honig, Kurt Horton, Jonathan I. Kamens, Peter King, Tom Kloos, Michael Lapsley, Casey Leedom, Jay Lepreau, Dave Lewis, Rick Linck, Soren Lundsgaard, Tad Mannes, Rob McMahon, Chris Metcalf, Mark Nagel, Ulf Noren, Marius Olafsson, Gene H. Olson, Henk P. Penning, Rick Perry, Larry Philps, Eric Putz, Jim Richardson, Michael Richardson, R. P. C. Rodgers, Kim Sanders, Mike Schwartz, Alan Silverstein, Lowell Skoog, Herr Soeryantono, Tim Theisen, Tom Tkacik, Andy Valencia, Adri Verhoef, Rick Walker, Petri Wessman, and Tim Wilson. ๐โจ
and that's a wrap on the whole page bestie, we ate that ๐ this was SC 7.16_1.1.3 241123 0424, dated April 14, 2016, and it's giving SC(1) main character energy ๐๐
the way we made it all the way to the end... iconic. go forth and spreadsheet ๐ฆ๐ธ
๐ฆ where this page comes from
- ubuntu resolute: sc 7.16-1.1.3-1
- ubuntu stonking: sc 7.16-1.1.3-1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms