Petr Skocik
Petr Skocik

Reputation: 60058

<cr> doesn't work with `normal!`

I tried:

$ vi +'help|only|set nu|execute "normal! 48G<cr>zt"'

But the zt part doesn't apply. (48 is the Getting Started line)

Could someone please explain why the zt part doesn't work and why this:

$ vi +'help|only|set nu|execute "normal! /^Getting<cr>zt"'

doesn't even apply the search for /^Getting.

Upvotes: 1

Views: 169

Answers (1)

edi9999
edi9999

Reputation: 20554

You don't need a <cr> after a G command.

vi +'help|only|set nu|execute "normal! 48Gzt"'

works fine for me.

Additionally, you need to specify the Enter character instead of <cr> (which you can write by typing Ctrl-V and then the Enter key) if you want to use search.

The command shows up like this :

vi +'help|only|set nu|execute "normal! /^Getting^Mzt"'

But the ^M is actually the Ctrl-v-Enter binding

Upvotes: 3

Related Questions