The easiest way to explain this question is to show you my code and what I am trying to do.
Here is some code, before any edits are made:
// some block of code here
// blaa blaa
// please imagine these comments are code
// another block of code after some whitespace break between
// this block and the previous
// blaa blaa
// please imagine these comments are code
Now imagine I want to edit "in-between" the 2 blocks of code above. I enter insert mode when the caret is between the blocks (on the whitespace line) I add some lines of whitespace (an extra 2), go up a line and enter a new variable name.
// some block of code here
// blaa blaa
// please imagine these comments are code
double a_very_long_variable_name = 0.0;
// another block of code after some whitespace break between
// this block and the previous
// blaa blaa
// please imagine these comments are code
Now I escape from insert mode (back to normal mode) and yank the variable name "a_very_long_variable_name" using "yiw" (yank in word) command.
I go down 1 line, to the blank line and press "p" to put. I get this.
// some block of code here
// blaa blaa
// please imagine these comments are code
double a_very_long_variable_name = 0.0;
a_very_long_variable_name
// another block of code after some whitespace break between
// this block and the previous
// blaa blaa
// please imagine these comments are code
What I want is to "put", but to add a new whitespace line (a newline character) after the put command.
- Is there already a command to do this? It seems like something that would be frequently required.
I believe I can accomplish this by creating a new command like this in my vimrc. (I am not sure yet what the nmap syntax is... Will search for this now.)
nmap <S-p> p$i<Enter><Esc>
Edit: The command above should actually be:
nnoremap <S-p> p$a<CR><Esc>
]pwill be forced to be line-wise which will have a similar behavior to:put. Unimpaired also has[<space>/]<space>mappings which make adding whitespace more pleasant. – Peter Rincker Jan 24 '18 at 15:09