Is there any way to get data with in braces, before a certain latex command (\body) and assign that content (long text) to a variable.
eg:
\text{just a text before body} \body{contains lot of paragraphs etc etc etc, and that paragraphs also contains lot of latex command like \textbf{my name} and \textit{text} etc. but i want all the content with in the brace} \text{just a text after body}
i need
\body{contains lot of paragraphs etc etc etc, and that paragraphs also contains lot of latex command like \textbf{my name} and \textit{text} etc. but i want all the content with in the brace} in a variable
I want some search and replace in it. thats why
i did a macro to yank text with in braces by the help of % (to search with in braces).
is there any easy way to do this?
thanks in advance
You can assign everything inside the {
to register a
using
"ayi{
Breakdown is
"a - select register a
y - yank
i{ - everything inside {}
It does the right thing for matching braces
If you later need to access the contents of a you can do this in multiple different ways depending on the context - I think the ways are
"ap : paste register a in normal mode
<C-r>a : paste register a into command line
@a : access register in script
It's worth noting that regex is not powerful enough to do matching braces. (I think there are extensions that can make it powerful enough, but I'm not sure if vim supports any of those),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With