set-option

vi shell option

Selects vi-style Readline editing. In insert mode Escape enters command mode; 0 moves to the start and i returns to insert mode. This is shell line editing, not a full vi editor. The fixture uses default key bindings. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Use interactive Bash with default key bindings; expected visible result: edited.

Formal Syntax & Structure

bash syntaxbash
set -o vi; set +o vi

Return Value

exit status

Returns zero on success and nonzero on failure; option queries return zero when enabled.

Working Example

Example Snippetbash
# In fresh interactive Bash:set -o vi# Type: 'edited\n' (without Enter), Escape, 0, i, then printf and a space, then Enter.
Bash Reference