Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to paste in the line where the cursor is?

The command p pastes below the cursor and P pastes above the cursor. What's the command to paste in the line where cursor is?

like image 210
Kitcha Avatar asked Feb 21 '12 19:02

Kitcha


People also ask

How do you paste a yanked 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 .

How do I paste a line?

Highlight the text you want to copy. Use the shortcut key combination Ctrl + C on a PC or Command + C on a Mac to copy the text. Move the text cursor to where you want to paste the text. Press Ctrl + V on a PC or Command + V on a Mac to paste the text.

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

Therefore, the key sequence would from command mode, A to get into insert mode at end of line, <space> to insert a space, then Ctrl-v to paste. Alternatively, while in insert mode, use the mouse to put the cursor at the end of a line, <space> then Ctrl-v .


2 Answers

This all depends on the type of data in the register you're pasting. If the data is line-oriented data (yanked with yy for instance) it will be pasted as a whole line above or below the cursor. If the data is character-oriented (yanked with e.g. y2w) then it will be pasted at or before the cursor position in the current line.

See :help linewise-register for more info on the interaction between the type of register and the put command.

like image 135
Randy Morris Avatar answered Oct 06 '22 12:10

Randy Morris


The Edit menu in gvim lists the following:

  • Paste = "+gP

  • Put Before = [p

  • Put After = ]p

If you're running vim in Windows, you can do the following to get Ctrl+C and Ctrl+V to work as expected:

source $VIMRUNTIME/mswin.vim behave mswin 
like image 20
Matthew Strawbridge Avatar answered Oct 06 '22 11:10

Matthew Strawbridge