{
    "id": "ed_cheat_sheet",
    "name": "ed",
    "description": "Basic commands for ed, a line-oriented text editor",
    "metadata": {
        "sourceName": "Freebsd",
        "sourceUrl": "https://www.freebsd.org/cgi/man.cgi?ed%281%29"
    },
    "template_type": "terminal",
    "section_order": [
        "Editing Commands",
        "File Manipulation Commands",
        "Display Commands",
        "Other Commands",
        "Addressing",
        "Invocation"
    ],
    "sections": {
        "Invocation": [
            {
                "key": "[ed \\[parameters\\] \\[filename\\]]",
                "val": "Invoke ed(1) with optional parameters and/or filename"
            },
            {
                "key": "[-p \\[string\\]]",
                "val": "Use [string] as a prompt"
            },
            {
                "key": "[-s]",
                "val": "Suppress diagnostics (should be used if ed(1) is run from a script)"
            },
            {
                "key": "[-x]",
                "val": "Prompt for a DES encryption key (BSD only)"
            },
            {
                "key": "[-r]",
                "val": "Use \"restricted\" mode (GNU only)"
            },
            {
                "key": "[-v]",
                "val": "Use \"verbose\" mode (GNU only)"
            }
        ],
        "Addressing" : [
            {
                "key": ".",
                "val": "The current line"
            },
            {
                "key": "$",
                "val": "The last line"
            },
            {
                "key": "[number]",
                "val": "The specified line number"
            },
            {
                "key": "/pattern/",
                "val": "The next line containing [pattern]"
            },
            {
                "key": "?pattern?",
                "val": "The previous line containing [pattern]"
            },
            {
                "key": "+[number]",
                "val": "[number] lines after the current line"
            },
            {
                "key": "-[number]",
                "val": "[number] lines before the current line"
            },
            {
                "key": "'{letter}",
                "val": "A line marked with {letter} (see the [k] command below)"
            }
        ],
        "Editing Commands": [
            {
                "key": "[.]a",
                "val": "Insert below the current line, end with a single period"
            },
            {
                "key": "[.,.]c",
                "val": "Change the specified range, end with a single period"
            },
            {
                "key": "[.,.]d",
                "val": "Delete the specified range"
            },
            {
                "key": "[.]i",
                "val": "Insert above the current line, end with a single period"
            },
            {
                "key": "[.,+]j",
                "val": "Join the specified range"
            },
            {
                "key": "[.,.]m[.]",
                "val": "Move the specified range"
            },
            {
                "key": "[.,.]s/regexp/replacement/flags",
                "val": "Perform a substitution on the specified range"
            },
            {
                "key": "[.,.]t[.]",
                "val": "Copy the specified range"
            },
            {
                "key": "[.]x",
                "val": "Paste the cut buffer (GNU extension)"
            },
            {
                "key": "[.,.]y",
                "val": "Copy (yank) the specified range (GNU extension)"
            },
            {
                "key": "[.]klc",
                "val": "Mark a line with a  lower case letter lc"
            }
        ],
        "File Manipulation Commands": [
            {
                "key": "e \\[filename\\]",
                "val": "Edit the file [filename]"
            },
            {
                "key": "e !\\{command\\}",
                "val": "Edit the output of {command}"
            },
            {
                "key": "E \\[filename\\]",
                "val": "Edit the file [filename] unconditionally"
            },
            {
                "key": "f \\[filename\\]",
                "val": "Set the default filename"
            },
            {
                "key": "\\[$\\]r \\[filename\\]",
                "val": "Read data from [filename] after the specified line"
            },
            {
                "key": "\\[$\\]r !\\{command\\}",
                "val": "Read output from {command} after the specified line"
            },
            {
                "key": "\\[1,$\\]w \\[filename\\]",
                "val": "Write the specified range to [filename] unconditionally"
            },
            {
                "key": "\\[1,$\\]wq \\[filename\\]",
                "val": "Write the specified range to [filename] unconditionally and quit"
            },
            {
                "key": "\\[1,$\\]W \\[filename\\]",
                "val": "Append the specified range to [filename] unconditionally"
            },
            {
                "key": "!command",
                "val": "Execute {command} via [sh(1)]"
            },
            {
                "key": "q",
                "val": "Quit"
            },
            {
                "key": "Q",
                "val": "Quit unconditionally"
            },
            {
                "key": "x",
                "val": "Prompt for the DES encryption key (BSD extension)"
            }
        ],
        "Display Commands": [
            {
                "key": "h",
                "val": "Print help on the last error"
            },
            {
                "key": "H",
                "val": "Toggle printing of errors"
            },
            {
                "key": "[.]l",
                "val": "Display the specified range unambiguously"
            },
            {
                "key": "[.]n",
                "val": "Number and print the specified range"
            },
            {
                "key": "[.]p",
                "val": "Print the specified range"
            },
            {
                "key": "P",
                "val": "Toggle command-prompt printing"
            },
            {
                "key": "[.+1]z{N}",
                "val": "Display N lines of text"
            },
            {
                "key": "[.,.]p",
                "val": "Print the addressed lines"
            },
            {
                "key": "[.,.]n",
                "val": "Print the addressed lines along with their line numbers"
            }
        ],
        "Other Commands": [
            {
                "key": "[1,$]g/\\{re\\}/\\{command-list\\}",
                "val": "Execute {command-list} on all lines matching {re}"
            },
            {
                "key": "[1,$]G/{re}/",
                "val": "Interactively edit all lines matching {re}"
            },
            {
                "key": "[.]k\\{letter\\}",
                "val": "Mark the line with the specified lower-case letter"
            },
            {
                "key": "u",
                "val": "Undo"
            },
            {
                "key": "[1,$]v/re/\\{command-list\\}",
                "val": "Execute {command-list} on all lines that do not match {re}"
            },
            {
                "key": "[1,$]V/re/",
                "val": "Interactively edit all lines that do not match {re}"
            },
            {
                "key": "[$]=",
                "val": "Print the line number of the addressed line"
            },
            {
                "key": "[.+1]{newline}",
                "val": "Print and select the addressed line"
            },
            {
                "key": "[.,.]#",
                "val": "Comment the remainder of the line (GNU extension)"
            }
        ]
    }
}

