For writing a text book I would like text expansion; on typing this:


it should expand this to:


I tried to use simple text replacement with :s%/TEXT/NEWTEXT/gc, but problem is my requirement with three arguments vim should wrap some text around three arguments.

The same problem exists with iabbrev, plus iabbrev requires typing TEXT and then a space.

How can I achieve this in Vim?


You can change any set of numbers (e.g. 24,10,4 to $24\ux,10uy,4uz$) with something like this:

  • I tried in ESC mode, but it says invalid argument. Pls help Sep 3 '16 at 9:40
  • @RamaKrishnaMajety Because the plus has to be escaped. Put a backslash before each one. (but I don't think this is the invalid argument problem)
    – Al.G.
    Sep 3 '16 at 11:26
  • 1
    I forgot the : - it's a substitution. The plus doesn't need to be escaped, since I use the very magic \v switch.
    – VanLaser
    Sep 3 '16 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.