Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: paste after last space?

Tags:

vim

I often want to paste some text after the last space in line. If I have

sometext <cursor>

and press Ctr+O, P, I got

sometext<pasted_text>

instead

sometext <pasted_text>

How do I achieve the latter in vim?

like image 582
mikea Avatar asked Oct 07 '09 19:10

mikea


People also ask

How do you paste to the next line?

Paste the line by pressing p . That will put the yanked line right under your cursor (on the next line). You can also paste before your current line by pressing the capital letter P .

What is paste mode Vim?

In Python, code blocks like loops are denoted using text indentation. To avoid this from happening, you can use Vim's paste mode. When you enable paste mode, Vim will not auto-indent any text that you paste. To enable paste mode, follow this process: In Vim, ensure you are command mode by hitting the Esc key.

How do I copy and paste multiple files in Vim?

If you opened the two files in two different instances of Vim, then you have to go with the system clipboard: in the first Vim instance, yank the text into the system clipboard using "+y (again, mark the area to be yanked in visual mode before), then go to the second Vim and paste the clipboard there: "+p .


2 Answers

Are you using (upper-case) P? That inserts text before the current cursor position. Lower-case p puts it after.

like image 89
Cascabel Avatar answered Nov 26 '22 14:11

Cascabel


If your line is

sometext$

where $ is the end of the line, then try o<Esc>pkJ to get

sometext pastedtext$

If your line is

sometext $

then just do $p to get

sometext pastedtext$
like image 44
rampion Avatar answered Nov 26 '22 15:11

rampion