In vi normal mode, the cursor is on the current line.
Create an empty line directly below it and enter insert mode.
Which key should be pressed?
In normal mode, o opens a new line below the current line and enters insert mode. O opens one above.
Detailed explanation
oCorrect. o opens a new line below the current line and switches to insert mode.
Correct. o opens a new line below the current line and switches to insert mode.
OIncorrect. Uppercase O opens a line above the current line.
Incorrect. Uppercase O opens a line above the current line.
aIncorrect. a enters insert mode after the cursor but does not open a new line.
Incorrect. a enters insert mode after the cursor but does not open a new line.
iIncorrect. i enters insert mode before the cursor without creating a line.
Incorrect. i enters insert mode before the cursor without creating a line.
Try it yourself
An example you can run in a temporary verification environment.
printf 'one\n' > sample.txt; vim -Nu NONE -n -es sample.txt -c 'execute "normal! oadded\<Esc>"' -c 'wq'; cat sample.txtExpected result
one
addedKey points
- o opens below
- O opens above
- The command enters insert mode
Notes
- Environment: Vim 9.x(vi互換操作)
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.