kay samy wrote:
> I have a file with the following text as a portion.
> ...
> cuuuuuuuuC
> {wdwdwGBh}
> {DwdwdrdW}
> {WDPdRDpD}
> {DwdkDb$W}
> {PdWdwDNd}
> {DWDWdWdW}
> {WDPDNDWD}
> {DWDWDWIW}
> vllllllllV
> ...
>
> I want to merge all the lines starting with { and ending with } to be
> merged into a SINGLE line.
> ...
> cuuuuuuuuC
> {wdwdwGBh} {DwdwdrdW} \{WDPdRDpD} {DwdkDb$W} {PdWdwDNd} {DWDWdWdW}
> {WDPDNDWD}{DWDWDWIW}
> vllllllllV
> ...
> How do I do this? Thanks a lot.
Making a few assumptions, this does the trick for me:
:g/^{/,/^[^{]/-j
Assumptions:
1) the stray "\" in your results was a mis-type
2) the last line of the file starts with something
other than "{"
3) all the lines with "{...}" are at the beginning-of-line
with no leading space/punctuation
To break that down:
g/ on every line that matches the following pattern
^{ a "{" at the beginning of the line
/ perform the following action
, from the current line through
/^[^{] the next line that doesn't start with a "{"
- adjust the ending line back one
(to exclude the non-"{" line)
j join them together
Hope this helps,
-tim
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---