Home Explore Blog CI



neovim

15th chunk of `runtime/doc/change.txt`
e2e235a1fb25a3039edc2e0885971c415ab60ac44c21f6f10000000100000fa1
 an optional
			expression.  The expression continues until the end of
			the command.  You need to escape the '|' and '"'
			characters to prevent them from terminating the
			command.  Example: >
				:put ='path' .. \",/test\"
<			If there is no expression after '=', Vim uses the
			previous expression.  You can see it with ":dis =".

:[line]pu[t]! [x]	Put the text [from register x] before [line] (default
			current line).

							*:ip* *:iput*
:[line]ip[ut] [x]	like |:put|, but adjust indent to the current line

:[line]ip[ut]! [x]	like |:put|!, but adjust indent to the current line

["x]]p		    or					*]p* *]<MiddleMouse>*
["x]]<MiddleMouse>	Like "p", but adjust the indent to the current line.
			Using the mouse only works when 'mouse' contains 'n'
			or 'a'.

["x][P		    or					*[P*
["x]]P		    or					*]P*
["x][p		    or					*[p* *[<MiddleMouse>*
["x][<MiddleMouse>	Like "P", but adjust the indent to the current line.
			Using the mouse only works when 'mouse' contains 'n'
			or 'a'.

["x]zp		    or					*zp* *zP*
["x]zP			Like "p" and "P", except without adding trailing spaces
			when pasting a block.  Thus the inserted text will not
			always be a rectangle.  Especially useful in
			combination with |v_zy|.

You can use these commands to copy text from one place to another.  Do this
by first getting the text into a register with a yank, delete or change
command, then inserting the register contents with a put command.  You can
also use these commands to move text from one file to another, because Vim
preserves all registers when changing buffers (the CTRL-^ command is a quick
way to toggle between two files).

				*linewise-register* *charwise-register*
You can repeat the put commands with "." (except for :put) and undo them.  If
the command that was used to get the text into the register was |linewise|,
Vim inserts the text below ("p") or above ("P") the line where the cursor is.
Otherwise Vim inserts the text after ("p") or before ("P") the cursor.  With
the ":put" command, Vim always inserts the text in the next line.  You can
exchange two characters with the command sequence "xp".  You can exchange two
lines with the command sequence "ddp".  You can exchange two words with the
command sequence "deep" (start with the cursor in the blank space before the
first word).  You can use the |']| or |`]| command after the put command to
move the cursor to the end of the inserted text, or use |'[| or |`[| to move
the cursor to the start.

						*put-Visual-mode* *v_p* *v_P*
When using a put command like |p| or |P| in Visual mode, Vim will try to
replace the selected text with the contents of the register.  Whether this
works well depends on the type of selection and the type of the text in the
register.  With blockwise selection it also depends on the size of the block
and whether the corners are on an existing character.  (Implementation detail:
it actually works by first putting the register after the selection and then
deleting the selection.)
With |p| the previously selected text is put in the unnamed register (and
possibly the selection and/or clipboard).  This is useful if you want to put
that text somewhere else.  But you cannot repeat the same change.
With |P| the unnamed register is not changed (and neither the selection or
clipboard), you can repeat the same change. But the deleted text cannot be
used.  If you do need it you can use |p| with another register.  E.g., yank
the text to copy, Visually select the text to replace and use "0p .  You can
repeat this as many times as you like, and the unnamed register will be
changed each time.
							*blockwise-put*
When a register contains text from one line (characterwise), using a
blockwise Visual selection, putting that register will paste that text
repeatedly in each of the selected lines, thus replacing the blockwise
selected region by multiple copies of the register text.  For example:
	- yank the word "TEXT" into a register with `yw`
	- select a visual block, marked with

Title: Vim: Advanced Putting and Visual Mode Interactions
Summary
This section continues to elaborate on the `put` command, including the indent-adjusting variants `:iput` and the bracketed `]p` and `[p` commands. It also describes the `zp` and `zP` variants, which don't add trailing spaces when pasting blocks. The section then explains how yank and put commands can be used to copy and move text between files. It also covers the interaction of put commands with Visual mode, detailing how the selected text is replaced by the register contents. It covers how the unnamed register behaves differently between `p` and `P`.