Copy a word and paste it over other words: Copy a line and paste it over other lines: Deleting, changing and yanking text copies the affected text to the unnamed register (""). Yanking text also copies the text to register 0 ("0). So the command yiw copies the current word to "" and to "0. Typing viw selects the current word, then pressing p pastes the unnamed register over the visual selection. The visual selection that was just replaced is then stored in the default unnamed register. let mapleader="," xnoremap p "_dP And then the workflow would be: yiw, move, viw,p, move again, viw,p, etc
Attributes | Values |
---|
rdfs:label
| - Replace a word with yanked text
|
rdfs:comment
| - Copy a word and paste it over other words: Copy a line and paste it over other lines: Deleting, changing and yanking text copies the affected text to the unnamed register (""). Yanking text also copies the text to register 0 ("0). So the command yiw copies the current word to "" and to "0. Typing viw selects the current word, then pressing p pastes the unnamed register over the visual selection. The visual selection that was just replaced is then stored in the default unnamed register. let mapleader="," xnoremap p "_dP And then the workflow would be: yiw, move, viw,p, move again, viw,p, etc
|
Version
| |
dbkwik:vim/property/wikiPageUsesTemplate
| |
Previous
| |
Text
| - YankRing
- ReplaceWithRegister
|
Author
| |
Complexity
| |
Created
| |
ID
| - 605(xsd:integer)
- 1234(xsd:integer)
- 2703(xsd:integer)
|
NEXT
| |
Rating
| |
abstract
| - Copy a word and paste it over other words: Copy a line and paste it over other lines: Deleting, changing and yanking text copies the affected text to the unnamed register (""). Yanking text also copies the text to register 0 ("0). So the command yiw copies the current word to "" and to "0. Typing viw selects the current word, then pressing p pastes the unnamed register over the visual selection. The visual selection that was just replaced is then stored in the default unnamed register. As you can see in the examples above, if you want to paste the same thing a second time, then you must use the "0 register, as in viw"0p. A workaround is to remap the p command in visual mode so that it first deletes to the black hole register like so: xnoremap p "_dP Note, using P in the remap replicates the default visual mode p function. Feel free to test. And you'd use xnoremap instead of vnoremap, according to the docs. Now you don't have to worry about pasting from the "0 register each subsequent time. However, this remapping prevents you from pasting from other registers in visual mode. So viw"ap to paste from the "a register is now broken. This script may solve that. Alternatively, I guess you could use a leader key instead such as: let mapleader="," xnoremap p "_dP And then the workflow would be: yiw, move, viw,p, move again, viw,p, etc
|