Constant COMMAND_DOCUMENTATION

Source
pub const COMMAND_DOCUMENTATION: &str = "# Command notation\n\nShort representations to keep this documentation concise.\n\n(Note that the descriptions of what a shorthand should be replaced by will use\nthe previously presented shorthands.)\n\n- `(x)` An optional `x`.\n- `x|y` `x` or `y`, and not both.\n- `[abc]` Any combination of `a`, `b` or `c`, but no duplicates.\n- `.` An index. Can be any of\n  - `.` Interpreted as the start of the currently viewed selection in most cases\n    but as the end of the currently viewed selection when given to an appending\n    command (or as end of a selection).\n  - `<positive integer>` Interpreted as index of a line.\n  - `$` Interpreted as index of the last line, or 0 there are no lines.\n  - `\'<char>` Interpreted as index of first line tagged with\n    the given character.\n  - `/<pattern>/` Interpreted as index of nearest following\n    line matching the given regex pattern.\n  - `?<pattern>?` same as above but nearest preceeding.\n  - `(<any index>)+(<positive integer>`) Interpreted as the other index plus\n    the positive integer. If no other index given treated as `.`. If no integer\n    given treated as `1`.\n  - `(<any index>)-(<positive integer>)` Same as above but minus.\n  - `<nothing>` Is generally equivalent to `.` if an index is accepted.\n    (Exceptions exist, as noted by the commands below.)\n- `.,.` A selection. Can be any of\n  - `.` Any lone index, which selects only that line. Errors if no line exists\n    at the index.\n  - `.,.` Two indices separated by a comma, which selects both those lines and\n    all lines between. Errors if any of the selected lines doesn\'t exist.\n    (Empty indices are interpreted as index `1` and `$` respectively.)\n  - `.;.` Two indices separated by a semicolon, which selects both those lines\n    and all lines between them. Erors if any of the selected lines doesn\'t\n    exist.\n    (Empty indices are interpreted as index `1` and `.` respectively.)\n  - `<nothing>` Interpreted as the currently viewed selection. Use the `=`\n    command to print the currently viewed selection.\n- `/` A separator. Can be any character (except newline), but for each command\n  invocation you must use the same separator. Traditionally `/` or `_`.\n\n\n# Printing flags:\n\nAll the printing commands and most other commands accept *printing flags*. These\nare `[pnl]`.\n- `p` prints the selection after the command.\n- `n` prints the selection after the command with line numbers (or without, if\n  the `N` default is on).\n- `l` prints the selection after the command with `$` before newlines, `--->`\n  instead of tabs and `$$` instead of `$`. (Or not, if the `L` default is on).\n\n\n# Printing commands\n\nCommands to print buffer contents.\n\n- `<nothing>` Prints as many lines after the currently selected as you have\n  selected. (Intended so you can print the first 20 lines and press enter to do\n  so again.)\n- `(.,.)[pnl]` Print given selection.\n  (`p` is used to distinct the invocation from `<nothing>` when not giving an\n  explicit selection, it doesn\'t affect the printing.)\n- `(.,.)z(<positive integer>)[pnl]` Prints the given number of lines following\n  the given selection with the given printing configuration.\n\n\n# Basic editing commands\n\nSimple commands to edit the text in the editing buffer.\n\n- `(.)a[pnl]` Append text after given line. Enters input mode terminated by \'.\'.\n  After running the inserted text is selected.\n- `(.)i[pnl]` Insert text before given line. Otherwise same behaviour as `a`.\n- `(.,.)d[pnl]` Cut the selected lines into (editor internal) clipboard. Selects\n  the nearest following line if any, otherwise the nearest preceeding. If\n  deleting all of the buffer there is no selection after running, wherefore\n  doing so with print flags will error.\n- `(.,.)y[pnl]` Copy the selected lines into (editor internal) clipboard.\n  Selects the given selection.\n- `(.)x[pnl]` Paste the contents of the (editor internal) clipboard after given\n  index. Selects the pasted lines.\n- `(.)X[pnl]` Same as `x` except pastes before the given index.\n- `(.,.)j[pnl]` Joins the selected lines into a single line (simply removes the\n  newline characters, everything else is kept). Selects the resulting line.\n\n\n# Combined editing commands\n\nCommands that kind of combine two basic editing commands.\n\n- `(.,.)c[pnl]` Change out the selected lines. Enters input mode terminated by\n  \'.\'. Equivalent to `.,.d` followed by `i`. Selects the inserted text if any\n  given, if none given behaves like `d`.\n- `(.,.)C[pnl]` *ONLY IF `initial_input_data` FEATURE IS ENABLED!!!*\n  Behaves just like `c` except the selected lines are put into the input field,\n  allowing you to edit them directly.\n- `(.,.)m(.)[pnl]` Move selected lines directly to given index. If no index\n  given it moves to the end of the buffer by default. Kind of equivalent to\n  `.,.d` followed by `x.`, except it doesn\'t affect the (editor internal)\n  clipboard. Selects the moved lines in their new location.\n- `(.,.)t(.)[pnl]` Copy selected lines directly to given index. If no index\n  given it copies to the end of the buffer by default. Kind of equivalent to\n  `.,.y` followed by `x.`, except it doesn\'t affect the (editor internal)\n  clipboard. Selects the copied lines in their new location.\n\n\n# File and shell commands\n\nCommands to read and write to the surrounding system, both directly to/from\nfiles and using shell commands.\n\nNote that most of these commands accept a shell command (prefixed by `!`). If\nsuch is given it will be run as a child process and read from (stdout)/written\nto (stdin) in place of the file path otherwise accepted. The last shell command\nrun is saved (no matter its success or failure) and can be re-run if no command\nis given. (For commands taking a path or a command you still need to give a `!`\nto indicate to run a command.)\n\n- `e(<path>|!<shell command>)` Replace buffer contents with data read from\n  given path/command. If no path/command given uses the default path. Sets the\n  default path to given path if path given, leaves default path unchanged\n  otherwise. Selects all lines in the buffer after reading in.\n  If the buffer contains unsaved edits aborts with error, capitalize `e` to `E`\n  to override the warning.\n- `(.)r(<path>|!<shell command>)` Read in data from give path/command and\n  insert it after the given index. If no index given defaults to inserting after\n  current selection. If no path or shell command given uses default path.\n  Selects the added lines after running.\n- `wq` Save the whole buffer to the default path and quit the editor. Errors if\n  it is given a selection other that the whole buffer.\n- `(.,.)w(<path>|!<shell command>)` Write selected lines to given\n  path/command. If no selection given writes the whole buffer. If no path given\n  writes to default path. If selection was explicitly given selects that,\n  otherwise leaves selection unchanged. If selection was not given and a path\n  was given that path is set as default path.\n- `(.,.)W(<path>)` Append the selected lines to the given path. If no path\n  given appends to default path. If no selection given appends whole buffer.\n  Selects the appended lines after running.\n- `(.,.)|(<shell command>)` Transform selection via given shell command. If no\n  selection is given the default selection is used. The original line data is\n  placed in the clipboard and the new lines are selected.\n- `!(<shell command>)` Run the given shell command interactively.\n\n\n# Batch editing commands\n\nMore advanced commands to apply the same or similar changes many times.\n\n- `(.,.)s(/<regex>/<substitution>/[gpnl])` Replaces text within selection that\n  matches the regex with the substitution. If the `g` flag is given replaces all\n  occurences of the regex, if not only the first is replaced. Selects the\n  selection, whatever size it ends up being after replacing.\n- `(.,.)g/<regex>/<command>(/)` Runs commands on all lines matching the regex.\n  If the last separator is given the commands are run immediately, if not it\n  enters input mode terminated by the separator. The matching line is selected\n  (using default selection, the commands will run them on the matched line) and\n  run in the order given. Doesn\'t set selection, but the commands run through\n  it do.\n- `(.,.)v/<regex>/<command>(/)` Inverse of `g`. Runs given commands on lines\n  that **don\'t** match the given regex.\n- `(.,.)G/<regex>/` Interactive version of `g`. For each matching line prints it\n   and enters input mode terminated by the separator. The given commands are run\n   on that line, same as `g`.\n- `(.,.)V/<regex>/` Inverse of `G`. Does the same for lines that don\'t match the\n   given regex.\n- `(.,.):<macro-name>(<space separated arguments>)` Set selection to given\n  selection (if any) and run given macro. Same as `g` it doesn\'t set selection,\n  but the commands in the macro will probably do so.\n\n  If the macro has specified number of arguments any other number will cause an\n  error. If and only if the allowed number of arguments is specified to none the\n  substitution routine won\'t be run, which means that \'$\' characters don\'t need\n  to be escaped (by adding another \'$\').\n\n\n# Status commands\n\nFor printing information about and changing editor state.\n\n- `help` Print a short list of commands.\n- `Help` Print this documentation.\n- `q` Quits the editor. If the buffer contains unsaved edits aborts with error.\n  Capitalize \'q\' to \'Q\' to override and quit anyways.\n- `h` Print last previous error.\n- `H` Toggle between printing the error or only `?` when an error occurs.\n- `(.,.)=` Prints selection. If none given prints the current selection.\n- `(.,.)#(<anything>)` If no selection is given it does nothing, to enable\n  inlining comments in scripts. If a selection is given that selection is set\n  without printing (this is the only way to do this, as even no command prints).\n- `f(<path>)` If no path given prints the default path, otherwise sets the given\n  path as default path.\n";
Expand description

Longer help text/manual, generally printed when “Help” is entered as a command.