6

How can I use something like this?

:g/^$/kJ

Here kJ are two commands, instead of just one (like 'd')

My concrete example: I have multiple lines looking like this

queryBuilder
    .append("xyz");

and I want to make them look like this:

queryBuilder.append("xyz");

So what I want to do for each line is

:g/^[\t]*\..*$/kJx

which matches the correct pattern but seems to execute only k.

Are other vim commands suitable here? How would you perform this task?

kadrian
  • 4,761
  • 8
  • 39
  • 61

1 Answers1

10

Add the normal instruction to execute all of them, like:

:g/^[\t]*\..*$/normal kJx
Birei
  • 35,723
  • 2
  • 77
  • 82
  • awesome! exactly what I needed! what does 'normal' actually do? – kadrian Jul 16 '12 at 20:33
  • 2
    @ka2011r: `:g` lets you run `ex` commands (which begin with colon), `:normal` is an `ex` command that lets you execute Normal commands, those that you wanted, `k`, `J` and `x`. – Birei Jul 16 '12 at 20:44