A shortcut to add a line
In my current project I end up typing this line a lot
Then show me the page
How should I create a shortcut mapping 开发者_如何学Goso that if I am on a line and hit that shortcut then a new line just below the current line is created and the above mentioned line is added.
It would be nice if the newly added line has the same indentation as the above line.
I am using MacVim.
From normal mode, you can type, or add this line to your vimrc:
:nmap Q oThen show me the page<cr><esc>
This just plays back the keystrokes to o
pen a new line below the current one (with correct indentation), type the characters, press enter for a linebreak, then exit insert mode.
I chose the keystroke Q, but this overwrites something else. You might choose a different keystroke instead...
yyp will copy the line (yy) and paste below the line (p)
yyP will paste a copy of the line above the present line (P)
精彩评论