vim: Move line containing pattern to the end of above line
regex, vim
Solution
Using
:norm J
would work for your current input but I assume that the search is mandatory so you can use a global command like this
:g/\vA\(.{-}\)/normal kJ
Breakdown
g -- start global command
\vA\(.{-}\)/ -- search for A followed by (<anything>)
normal kJ -- for each match, execute k (line up), J (join lines)
Edit (cudo's to Peter)
As `-j` in command-line mode is equivalent with `kJ` in normal, you can shorten this to
:g/\vA\(.{-}\)/-j
or even shorter
:g/\vA\(.*\)/-j
but personally I prefer the lazy ({-}) instead of the greedy (*) quantifier.
Problem
``` A : A() A : A(int) to A : A() A : A(int) ``` A() is the pattern I'm searching for (multi-line) and trying to append it to the previous line.