Imagine that I have the following text:
This is a \st{very nice}\MG{not so great} sample text.
Is there a way that having the cursor in any place of the string "\st{very nice}" or "\MG{not so great}" a macro could convert them to "" (deletes everything) or "not so great" (accepts the change)?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
be able to place the cursor inside nested commands.
behave differently depending on the command found.
Basically it searches for a command that looks like \MG or \st and finds its matching }. Then it "accepts the change", i.e. it removes the content if the command was \st and it keeps the content if the command was \MG.
Now I'm only missing spanning multiple lines and giving a warning if it fails.
Imagine that I have the following text:
This is a \st{very nice}\MG{not so great} sample text.
Is there a way that having the cursor in any place of the string "\st{very nice}" or "\MG{not so great}" a macro could convert them to "" (deletes everything) or "not so great" (accepts the change)?
You can use indexOf/lastIndexOf to find the next {, } and \, replace everything between with selectColumns/replaceSelectedText:
Great! I tweeked the code a bit to:
Basically it searches for a command that looks like \MG or \st and finds its matching }. Then it "accepts the change", i.e. it removes the content if the command was \st and it keeps the content if the command was \MG.
Now I'm only missing spanning multiple lines and giving a warning if it fails.
Last edit: Miguel 2016-11-16