Reputation: 83
I'm trying to write a vim script for remove the text wrap, I am using the following code but it's doesn't provide exact output. eg \string{this indicate newline} if "this" appears in first line, "indicate" is in second line e.t.c then how I remove text wrap. Is it possible?
:%s/\\string{\zs\(\_[^}]*\)\ze}/\1/gec
for example (i/p): \string{1 <enterkey> 2 <enterkey> 3 <enterkey>
4 <enterkey> 5 <enterkey>}. i need (o/p) \string{1 2 3 4 5}.
Before I have:
\string{1
2
3
4
5
}
After I want:
\string{1 2 3 4 5}
Before I have (new pattern):
\string{1
{2}
{3}
4
5}
After I want:
\string{1 {2} {3} 4 5}
Upvotes: 0
Views: 99
Reputation: 195169
This line does what you want:
%s/\\string{\_[^}]*/\=substitute(submatch(0),"\n",' ','g')/
it changes:
foobar
\string{1
2
3
4
5
}
foobar
into:
foobar
\string{1 2 3 4 5 }
foobar
Upvotes: 2
Reputation: 5119
It would be easier to understand your question if you gave a longer example of text, and what you want to do with it. If I understand correctly, you could like to remove the line wrap on lines that contain \\string{this
.
You could use :%g/\\string{this/j
. It executes the j
command on every line matching the \\string{this
pattern.
Input:
some text
\string{this
indicate}
more text
Turns into:
some text
\string{this indicate}
more text
Upvotes: 1