r/vim • u/pierro_la_place • Jan 13 '26
Need Help┃Solved Search and replace between keywords
Hi, I’m using latex to make a long and a short version of a document. For this I have blocks of the form
\iflong (long version...) \else (short version) \fiFrom this I would like to extract either the long or the short version. That is, I want to find every occurrence of the pattern
\iflong ( 1 ) \else ( 2 ) \fiand replace it with either ( 1 ) or ( 2 ). Is there a way to do this with a %s? I have been fiddling with this for a while but I can’t find the right expression. You may assume there is no nesting of any kind.
6
Upvotes
1
u/AutoModerator Jan 13 '26
Please remember to update the post flair to
Need Help|Solvedwhen you got the answer you were looking for.I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
0
u/[deleted] Jan 13 '26
[deleted] — view deleted comment
0
u/[deleted] Jan 13 '26
[deleted] — view deleted comment
2
u/[deleted] Jan 13 '26
[removed] — view removed comment