How to save a Vim macro that contains “Escape” key presses?

前端 未结 7 1425
迷失自我
迷失自我 2020-12-14 07:43

I use the following Vim macro a lot (it puts the current line inside XML tags):

I^[A

So I saved it into my .vimrc

7条回答
  •  醉梦人生
    2020-12-14 08:17

    Saving macros in plain file without plugins.

    Having for example macro m . In insert mode, at e.g beginning of new line, then type 3 keys

    ctrl-r ctrl-r m

    the macro with escapes will be put in that line. (editable as needed) In another line name/comment it. Add other macros if you wish - then save this file as e.g. :w my_vim_macros

    When you want to reuse such saved macro(s): place cursor on the beginning of macro string, then 4keys

    "xy$

    and your macro (this line) will be yanked to register x.

提交回复
热议问题