开发者

vim shortcut to replace char under cursor with an expression?

开发者 https://www.devze.com 2023-03-26 13:11 出处:网络
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 fea

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 chan开发者_开发百科ge)
  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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消