Shortcut to add a line

In my current project, I end up typing this line a lot

Then show me the page 

How to create a shortcut mapping so that if I am in a line and click this shortcut, a new line is created just below the current line and the above line is added.

It would be nice if the newly added line has the same indentation as the line above.

I am using MacVim.

+4
source share
2 answers

In normal mode, you can enter or add this line to your vimrc:

 :nmap Q oThen show me the page<cr><esc> 

It just plays keystrokes on o , puts a new line under the current line (with the right indentation), types characters, press enter for the line, then exits insert mode.

I selected the Q key press, but this overwrites something else. Instead, you can choose another keystroke ...

+6
source

yyp will copy the line (yy) and paste under the line (p)

yyP inserts a copy of the line above the current line (P)

0
source

All Articles