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?
The exact sequence I'd like to map is:
binding.pry
to the newly created line.EDIT: binding.pry
is text I want to paste, not a file.
Before insert:
a = 1
b = 2
After insert:
a = 1
binding.pry
b = 2
Insert a Text boxPress and release ALT, N, and then press X. Press the arrow keys to select the Text box that you want, and then press ENTER. Type the text that you want. When you are finished typing and want to switch back to editing text in your document, press ESC.
Ctrl+M in Word and other word processors Ctrl+M is used to indent a paragraph in Microsoft Word and other word-processing software. The indent keeps growing if you repeatedly use this keyboard shortcut. To indent the paragraph by three units, for instance, hit M three times while holding down Ctrl.
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With