tags:

views:

79

answers:

2

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

Then show me the page

How should I create a shortcut mapping so 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.

+4  A: 

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 open 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...

Peter
Please explain how to call the shortcut.
Manuel Faux
@Manuel: Press shift+Q (that is, an uppercase Q) in normal mode. (See :help :nmap.)
Roger Pate
I mapped it using leader like this. nmap <leader>st oThen show me the page<esc> . I call it like ,st . My leader is mapped to ,
Nadal
A: 

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)

jacksnake