3

Say I perform a combination of keys and now they are registered in .

Now I want to go down X lines and run . on each one.

For example say I have:

{colorComponentId: 0, value: (value.warmWhite * 255)},
{colorComponentId: 1, value: (value.coldWhite * 255)},
{colorComponentId: 2, value: (value.red * 255)},
{colorComponentId: 3, value: (value.green * 255)},
{colorComponentId: 4, value: (value.blue * 255)}

I then run d/} just after value: resulting in:

{colorComponentId: 0, value:},
{colorComponentId: 1, value: (value.coldWhite * 255)},
{colorComponentId: 2, value: (value.red * 255)},
{colorComponentId: 3, value: (value.green * 255)},
{colorComponentId: 4, value: (value.blue * 255)}

I then found myself pressing down+. 4 more times.

{colorComponentId: 0, value:},
{colorComponentId: 1, value:},
{colorComponentId: 2, value:},
{colorComponentId: 3, value:},
{colorComponentId: 4, value:}

Is there are a way to say something like "do . down X times"?

4

You can use a macro, though it does require a (small) bit of planning ahead:

qqdt}jq4@q

will work, assuming your cursor is starting on the first line on the space after value:. Here's an explanation:

q
Start recording a macro...
 q
...in register `q`...
  dt}j
...delete until the next `}` and then go down one line...
      q
...finish recording the macro...
       4@q
...replay the macro in register `q` 4 times.
4

I would use a macro:

Juste before the deletion do:

qqdf)jq

Which means:

  • qq start to record a macro in the register q
  • df) your deletion
  • j go down one line
  • q stop recording the macro

Then you can press several time @q to replay the macro of the q register or simply 4@q to replay it 4 times.


Or you could go with a substitution:

Visually select the lines you want to modify and then:

:'<,'>s/(.*)//

Which means:

  • '<,'> between the selected line
  • s/ substitute
  • (.*) anything between the parenthesys
  • // replace it by nothing

See:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.