Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim shortcut to replace char under cursor with an expression?

Tags:

vim

latex

I'm processing an old text into latex.

All I have is an old pdf file, which I copy-paste bit by bit, replacing the ill-copied bits to fit latex code. The text contains a lot of inline math, and features a lot of different variables. Every variable is explained in-text and is thus named inline:

Zie figuur 3, waar R de weerstand voorstelt

What I do now is this:

  1. go to the relevant line
  2. in normal mode type f+R (where R is the char I need to change)
  3. i
  4. type \( before the char
  5. type \)after the char

voila, the char is now recognized by latex as a math char.

I would like to now if there isn't a quicker procedure that replaces steps 3 to 5?

like image 785
romeovs Avatar asked Feb 25 '26 04:02

romeovs


1 Answers

Record a macro. For example, if you want to save it in register a do the following:

fRqai\(<esc>la\)<esc>q

Now, once you're over the character you want, use @a. To repeat the last macro you can also use @@. So, an example of redoing it:

fR@a
like image 131
sidyll Avatar answered Feb 27 '26 16:02

sidyll