Insert predefined text on keyboard shortcut

后端 未结 6 948
悲&欢浪女
悲&欢浪女 2021-02-07 04:27

I often insert binding.pry to my ruby files when I debug them. As I use Vim I\'d love to automate it to avoid retyping it every time. How could I do it?

Th

6条回答
  •  礼貌的吻别
    2021-02-07 05:01

    Record a macro (untested)

    qq               " record macro to register q 
    o                " insert empty line below cursor
    esc              " exit insert-mode
    :r /path/to/binding.pry   " insert content of file
    esc              " cmd-mode
    q                " end recording
    

    To execute macro, do

    @q
    

    Or add the following to your .vimrc file

    update

    To insert the string binding.pry the mapping becomes:

    map ,p obinding.pry
    

提交回复
热议问题