Reputation: 386
I'm trying to search through a page for the word CREATE
. I would then like to put DELIMITER $$
above that line.
Here is my attempt. Can someone point me in the right direction?
:execute "%normal! /CREATE\<cr>"."O DELIMITER $$"."<esc>"
Am I on the right track?
Upvotes: 0
Views: 111
Reputation: 172530
Yes, you're close. To combine an action with a matching pattern, use the :global
command. For prepending text in a new line, there are actually multiple approaches: The normal-mode O
command can be used with :normal
, or you can :put
an expression =
(instead of register contents) containing the text.
:g/CREATE/normal! O$$
or
:g/CREATE/put! ='$$'
Upvotes: 2