Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paste text at the end of the line with a space between in vim

Tags:

vim

I'm trying to find a the fastest way to paste text at the end of the line, but with a space between the previous EOL and new text. The current method is a <ESC>p or o<ESC>pkJ. Is there any other, faster way to achive this? I'm thinking about something like "paste with offset"?

Original: The quick brown fox 
after $p: The quick brown foxjumps over the lazy dog
desired : The quick brown fox jumps over the lazy dog
like image 241
Sebastian Kramer Avatar asked Nov 15 '13 17:11

Sebastian Kramer


People also ask

How do I put text at the end of a line in Vim?

Insert "new text " at the beginning of the line. Append " new text" to the end of the line.

How do I paste a block of text in Vim?

Pasting over a block of text You can copy a block of text by pressing Ctrl-v (or Ctrl-q if you use Ctrl-v for paste), then moving the cursor to select, and pressing y to yank. Now you can move elsewhere and press p to paste the text after the cursor (or P to paste before).


1 Answers

If you do not want to use a mapping, you can type Aspacectrl+r".

See :h i_ctrl-r for more information. This is what is happening:

A        Append text to end of line (enters insert mode).
space  - Actual space key to insert a space.
ctrl+r - Insert contents of a register.
"      - Default register of yank and paste.
like image 171
cforbish Avatar answered Oct 21 '22 03:10

cforbish