vi editor command-line corrections — back up over typing errors When entering ex/vi commands (for example, after typing a colon), which historical erase character is commonly used to back up over a single typing error on terminals that do not support a true Backspace key?

Difficulty: Medium

Correct Answer: #

Explanation:


Introduction / Context:
Classic vi grew up on hard-copy and glass TTYs with limited keysets. Before modern Backspace behavior was standardized, terminal drivers provided special erase and kill characters for command-line editing. Knowing these legacy conventions helps when working on constrained systems or through raw serial consoles.



Given Data / Assumptions:

  • We are entering an ex command line in vi (for example, after typing :).
  • The terminal's erase and kill characters are configured to traditional defaults.
  • We want the character that erases one previous character (a single backspace effect).


Concept / Approach:

Historically, the hash mark # acted as the erase character, removing the immediately preceding character on the command line. The at sign @ often acted as the line-kill character, clearing the entire input line. While modern terminals support the Backspace key, these legacy controls still appear in documentation and older environments.



Step-by-Step Solution:

Enter command-line mode with : in vi.If you mistype, press # to erase the last character (on systems honoring this convention).Use @ to erase the whole line if necessary (legacy behavior).Press Enter to execute once the command is correct.


Verification / Alternative check:

Check your terminal settings with stty -a. The erase and kill characters show the current bindings, which may be Backspace and Ctrl+U in modern setups. If set to # and @, the described behavior will occur in vi's command-line entry.



Why Other Options Are Wrong:

  • @: typically the kill-line character (erase the whole line), not single-character erase.
  • $: represents end-of-line in regular expressions; not an erase character.
  • !: used for shell escapes in ex/vi commands (for example, :!ls), not for editing mistakes.
  • None of the above: incorrect because # is traditionally used for single-character erase in this context.


Common Pitfalls:

Assuming your modern Backspace will always work in raw terminals; not checking stty settings; confusing vi's insert-mode editing with ex command-line editing rules.


Final Answer:

#

More Questions from Unix

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion