Insert predefined text on keyboard shortcut

Easiest is an abbreviation that is triggered from insert mode:

:ia debug <CR>binding.pry

Now, when you type debug, the text binding.pry is inserted on a new line.

Documentation: :help abbreviations


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<ESC>

Tags:

Vim