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?
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 .
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.
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 .
Are you using (upper-case) P
? That inserts text before the current cursor position. Lower-case p
puts it after.
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$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With