This popped-up while writing a script for vim.
Using the well-documented ':normal' command:
:normal /abc
does not search for the string abc. Instead, the previous search string is still active (i.e highlighted, jumped to with n, etc.).
Even stranger: the abc appears as the newest pattern in the / history (i.e. hitting / and then an up-arrow).
How come the abc does not take over as the true search pattern?
The help file for indeed well-documented :normal
command says the following:
If
{commands}
does not finish a command, the last one will be aborted as if<Esc>
or<C-C>
was typed.
When you write:,
:normal /abc
you try to execute unfinished command. Indeed, after you type "/abc
" in insert mode, you also should press "Enter" (i.e. <CR>
). This doesn't happen, but, according to manual, <Esc>
is pressed.
To search via commands, you should use:.
:exec "/abc"