<p>Using Vim I often want to replace a block of code with a block that I just yanked.</p>

<p>But when I delete the block of code that is to be replaced, that block itself goes into the register which erases the block I just yanked. So I've got in the habit of yanking, then inserting, then deleting what I didn't want, but with large blocks of code this gets messy trying to keep the inserted block and the block to delete separate.</p>

<p>So what is the slickest and quickest way to replace text in Vim?</p>

<ul>
<li>is there a way to delete text without putting it into the register?</li>
<li>is there a way to say e.g. "replace next word" or "replace up to next paragraph"</li>
<li>or is the best way to somehow use the multi-register feature?</li>
</ul>

[{'answer_id': 54265, 'author': 'EBGreen', 'author_id': 1358, 'author_profile': 'https://Stackoverflow.com/users/1358', 'pm_score': 3, 'selected': False, 'text': "<p>Well, first do this command:</p>\n\n<pre><code>:h d\n</code></pre>\n\n<p>Then you will realize that you can delete into a specific register. That way you won't alter what is in your default register.</p>\n"}, {'answer_id': 54272, 'author': 'EBGreen', 'author_id': 1358, 'author_profile': 'https://Stackoverflow.com/users/1358', 'pm_score': 5, 'selected': False, 'text': '<p>For the specific example that you gave, if I understand the question then this might work:</p>\n\n<pre><code>*Highlight what you want to put somewhere else\n*delete (d)\n*Highlight the code that you want it to replace\n*paste (p)\n</code></pre>\n'}, {'answer_id': 54422, 'author': 'maeghith', 'author_id': 5614, 'author_profile': 'https://Stackoverflow.com/users/5614', 'pm_score': 3, 'selected': False, 'text': '<p>If you\'re using Vim then you\'ll have the visual mode, which is like selecting, but with the separating modes thing that\'s the basis of vi/vim.</p>\n\n<p>What you want to do is use visual mode to select the source, then yank, then use visual mode again to select the scope of the destination, and then paste to text from the default buffer.</p>\n\n<p>Example:</p>\n\n<p>In a text file with:</p>\n\n<pre>\n1| qwer\n2| asdf\n3| zxcv\n4| poiu\n</pre>\n\n<p>with the following sequence: <code>ggVjyGVkp</code> you\'ll end with:</p>\n\n<pre>\n1| qwer\n2| asdf\n3| qewr\n4| asdf\n</pre>\n\n<p>Explained:</p>\n\n<ul>\n<li><code>gg</code>: go to first line</li>\n<li><code>V</code>: start visual mode with whole lines</li>\n<li><code>j</code>: go down one line (with the selection started on the previous lines this grows the selection one line down)</li>\n<li><code>y</code>: yank to the default buffer (the two selected lines, and it automatically exits you from visual mode)</li>\n<li><code>G</code>: go to the last line</li>\n<li><code>V</code>: start visual mode (same as before)</li>\n<li><code>k</code>: go up one line (as before, with the visual mode enabled, this grows the selection one line up)</li>\n<li><code>p</code>: paste (with the selection on the two last lines, it will replace those lines with whatever there is in the buffer -- the 2 first lines in this case)</li>\n</ul>\n\n<p>This has the little inconvenient that puts the last block on the buffer, so it\'s somehow not desired for repeated pastings of the same thing, so you\'ll want to save the source to a named buffer with something like <code>"ay</code> (to a buffer called "a") and paste with something like <code>"ap</code> (but then if you\'re programming, you probably don\'t want to paste several times but to create a function and call it, right? <strong>RIGHT</strong>?).</p>\n\n<p>If you are only using vi, then youll have to use invisible marks instead the visual mode, <code>:he mark</code> for more on this, I\'m sorry but I\'m not very good with this invisible marks thing, I\'m pretty contaminated with visual mode.</p>\n'}, {'answer_id': 54434, 'author': 'Christian Berg', 'author_id': 5035, 'author_profile': 'https://Stackoverflow.com/users/5035', 'pm_score': 10, 'selected': True, 'text': '<p>To delete something without saving it in a register, you can use the "black hole register":</p>\n\n<pre><code>"_d\n</code></pre>\n\n<p>Of course you could also use any of the other registers that don\'t hold anything you are interested in.</p>\n'}, {'answer_id': 56186, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': "<p>Text deleted, while in insert mode, doesn't go into default register.</p>\n"}, {'answer_id': 58607, 'author': 'Swaroop C H', 'author_id': 4869, 'author_profile': 'https://Stackoverflow.com/users/4869', 'pm_score': 3, 'selected': False, 'text': "<p>For 'replace word', try <code>cw</code> in normal mode.</p>\n\n<p>For 'replace paragraph', try <code>cap</code> in normal mode.</p>\n"}, {'answer_id': 58637, 'author': 'dbr', 'author_id': 745, 'author_profile': 'https://Stackoverflow.com/users/745', 'pm_score': 7, 'selected': False, 'text': '<p>Yep. It\'s slightly more convoluted than deleting the "old" text first, but:</p>\n\n<p>I start off with..</p>\n\n<pre><code>line1\nline2\nline3\nline4\n\nold1\nold2\nold3\nold4\n</code></pre>\n\n<p>I <kbd>shift</kbd>+<kbd>v</kbd> select the line1, line 2, 3 and 4, and delete them with the <kbd>d</kbd> command</p>\n\n<p>Then I delete the old 1-4 lines the same way.</p>\n\n<p>Then, do</p>\n\n<pre><code>"2p\n</code></pre>\n\n<p>That\'ll paste the second-last yanked lines (line 1-4). <code>"3p</code> will do the third-from-last, and so on..</p>\n\n<p>So I end up with</p>\n\n<pre><code>line1\nline2\nline3\nline4\n</code></pre>\n\n<p><strong>Reference:</strong>\n<a href="http://vimdoc.sourceforge.net/htmldoc/change.html#quote_number" rel="noreferrer">Vim documentation on numbered register</a></p>\n'}, {'answer_id': 62959, 'author': 'JayG', 'author_id': 5823, 'author_profile': 'https://Stackoverflow.com/users/5823', 'pm_score': 2, 'selected': False, 'text': '<p>In the windows version (probably in Linux also), you can yank into the system\'s copy/paste buffer using <code>"*y</code> (i.e. preceding your yank command with double-quotes and asterisk).</p>\n\n<p>You can then delete the replaceable lines normally and paste the copied text using <code>"*p</code>.</p>\n'}, {'answer_id': 509557, 'author': 'alex2k8', 'author_id': 62192, 'author_profile': 'https://Stackoverflow.com/users/62192', 'pm_score': 6, 'selected': False, 'text': '<p>VIM docs: <em>Numbered register 0 contains the text from the most recent yank command,\nunless the command specified another register with ["x].</em></p>\n\n<p>E.g. we yank "foo" and delete "bar" - the registry 0 still contains "foo"! Hence "foo" can be pasted using <code>"0p</code></p>\n'}, {'answer_id': 920139, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 6, 'selected': False, 'text': "<p>It's handy to have an easy mapping which lets you replace the current selection with buffer.</p>\n<p>For example when you put this in your .vimrc</p>\n<pre><code>&quot; it's a capital 'p' at the end\nvmap r &quot;_dP\n</code></pre>\n<p>then, after copying something into register (i.e. with 'y'), you can just select the text which you want to be replaced, and simply hit 'r' on your keyboard. The selection will be substituted with your current register.</p>\n<p>Explanation:</p>\n<pre><code>vmap - mapping for visual mode\n&quot;_d - delete current selection into &quot;black hole register&quot;\nP - paste\n</code></pre>\n"}, {'answer_id': 1290230, 'author': 'Magnus', 'author_id': 136815, 'author_profile': 'https://Stackoverflow.com/users/136815', 'pm_score': 5, 'selected': False, 'text': "<p>I put the following in my vimrc:</p>\n<pre><code>noremap  y &quot;*y\nnoremap  Y &quot;*Y\nnoremap  p &quot;*p\nnoremap  P &quot;*P\nvnoremap y &quot;*y\nvnoremap Y &quot;*Y\nvnoremap p &quot;*p\nvnoremap P &quot;*P\n</code></pre>\n<p>Now I yank to and put from the clipboard register, and don't have to care what happens with the default register. An added benefit is that I can paste from other apps with minimal hassle. I'm losing some functionality, I know (I am no longer able to manage different copied information for the clipboard register and the default register), but I just can't keep track of more than one register/clipboard anyway.</p>\n"}, {'answer_id': 1555850, 'author': 'Clueless', 'author_id': 165876, 'author_profile': 'https://Stackoverflow.com/users/165876', 'pm_score': 2, 'selected': False, 'text': '<p>I often make a mistake when following the commands to \'y\'ank then \'"_d\'elete into a black hole then \'p\'aste. I prefer to \'y\'ank, then delete however I like, then \'"0p\' from the 0 register, which is where the last copied text gets pushed to.</p>\n'}, {'answer_id': 2557670, 'author': 'idbrii', 'author_id': 79125, 'author_profile': 'https://Stackoverflow.com/users/79125', 'pm_score': 4, 'selected': False, 'text': '<p>To emphasize what <a href="https://stackoverflow.com/questions/54255/in-vim-is-there-a-way-to-delete-without-putting-text-in-the-register/54272#54272">EBGreen said</a>:</p>\n\n<p>If you paste while selecting text, the selected text is <strong>replaced</strong> with the pasted text.</p>\n\n<p>If you want to copy some text and then paste it in multiple locations, use <code>"0p</code> to paste. Numbered register 0 contains the text from the most recent yank command.</p>\n\n<hr>\n\n<p>Also, you can list the contents of all of your registers:</p>\n\n<pre><code>:registers\n</code></pre>\n\n<p>That command makes it easier to figure out what register you want when doing something like <a href="https://stackoverflow.com/questions/54255/in-vim-is-there-a-way-to-delete-without-putting-text-in-the-register/58637#58637">dbr\'s answer</a>. You\'ll also see the /,%,# registers. (See also <code>:help registers</code>)</p>\n\n<hr>\n\n<p>And finally, check out <code>cW</code> and <code>cW</code> to change a word including and not including an trailing space. (Using capital <code>W</code> includes punctuation.)</p>\n'}, {'answer_id': 5370718, 'author': 'expelledboy', 'author_id': 644945, 'author_profile': 'https://Stackoverflow.com/users/644945', 'pm_score': 2, 'selected': False, 'text': '<p>The two solutions I use in the right contexts are;</p>\n\n<ul>\n<li>highlight what you want to replace using Vims <code>VISUAL</code> mode then paste the register.</li>\n</ul>\n\n<p>I use this mostly out of habit as I only found the second solution much later, eg </p>\n\n<pre><code>yiw   " yank the whole word\nviwp  " replace any word with the default register\n</code></pre>\n\n<ul>\n<li><a href="http://www.vim.org/scripts/script.php?script_id=1234" rel="nofollow">YankRing</a>. With this plugin you can use the keybinding <code>&lt;ctrl&gt;+&lt;p&gt;</code> to replace the previous numbered register with the one you just pasted.</li>\n</ul>\n\n<p>Basically you go about pasting as you would, but when you realise that you have since overwritten the default register thus losing what you actually wanted to paste you can <code>&lt;C-P&gt;</code> to find and replace from the YankRing history!</p>\n\n<p>One of those must have plugins...</p>\n'}, {'answer_id': 8533710, 'author': 'Vic Goldfeld', 'author_id': 985859, 'author_profile': 'https://Stackoverflow.com/users/985859', 'pm_score': 2, 'selected': False, 'text': '<p>For Dvorak users, one very convenient method is to just delete unneeded text into the "1 register instead of the "_ black hole register, if only because you can press " + 1 with the same shift press and a swift pinky motion since 1 is the key immediately above " in Dvorak (PLUS d is in the other hand, which makes the whole command fast as hell).</p>\n\n<p>Then of course, the "1 register could be used for other things because of it\'s convenience, but unless you have a purpose more common than replacing text I\'d say it\'s a pretty good use of the register.</p>\n'}, {'answer_id': 28726374, 'author': 'Hieu Nguyen', 'author_id': 1087430, 'author_profile': 'https://Stackoverflow.com/users/1087430', 'pm_score': 2, 'selected': False, 'text': '<p>I found a very useful mapping for your purpose:</p>\n\n<pre><code>xnoremap p "_dP\n</code></pre>\n\n<p>Deleted text is put in "black hole register", and the yanked text remains. </p>\n\n<p>Source: <a href="http://vim.wikia.com/wiki/Replace_a_word_with_yanked_text" rel="nofollow">http://vim.wikia.com/wiki/Replace_a_word_with_yanked_text</a></p>\n'}, {'answer_id': 32488853, 'author': 'Torben', 'author_id': 398844, 'author_profile': 'https://Stackoverflow.com/users/398844', 'pm_score': 4, 'selected': False, 'text': '<p><strong>A minimal invasive solution for the lazy ones:</strong></p>\n\n<p>Register <code>0</code> always contains the last yank (as <a href="/questions/54255/in-vim-is-there-a-way-to-delete-without-putting-text-in-the-register#comment-6335532">Rafael</a>, <a href="/questions/54255/in-vim-is-there-a-way-to-delete-without-putting-text-in-the-register#answer-509557">alex2k8</a> and <a href="/questions/54255/in-vim-is-there-a-way-to-delete-without-putting-text-in-the-register#answer-2557670">idbrii</a> have already mentioned). Unfortunately selecting register <code>0</code> all the time can be quite annoying, so it would be nice if <code>p</code> uses <code>"0</code> by default. This can be achieved by putting the following lines into your <code>.vimrc</code>:</p>\n\n<pre><code>noremap p "0p\nnoremap P "0P\nfor s:i in [\'"\',\'*\',\'+\',\'-\',\'.\',\':\',\'%\',\'/\',\'=\',\'1\',\'2\',\'3\',\'4\',\'5\',\'6\',\'7\',\'8\',\'9\',\'a\',\'b\',\'c\',\'d\',\'e\',\'f\',\'g\',\'h\',\'i\',\'j\',\'k\',\'l\',\'m\',\'n\',\'o\',\'p\',\'q\',\'r\',\'s\',\'t\',\'u\',\'v\',\'w\',\'x\',\'y\',\'z\']\n    execute \'noremap "\'.s:i.\'p "\'.s:i.\'p\'\n    execute \'noremap "\'.s:i.\'P "\'.s:i.\'P\'\nendfor\n</code></pre>\n\n<p>The first line maps each <code>p</code> stroke to <code>"0p</code>. However, this prevents <code>p</code> from accessing any other registers. Therefore all <code>p</code> strokes with an explicitly selected register are mapped to the equivalent commandline expression within the for-loop. The same is done for <code>P</code>.</p>\n\n<p>This way the standard behaviour is preserved, except for the implicit <code>p</code> and <code>P</code> strokes, which now use register <code>0</code> by default.</p>\n\n<p><strong>Hint 1:</strong> The cut command is now <code>"0d</code> instead of just <code>d</code>. But since I\'m lazy  this is way too long for me ;) Therefore I\'m using the following mapping:</p>\n\n<pre><code>noremap &lt;LEADER&gt;d "0d\nnoremap &lt;LEADER&gt;D "0D\n</code></pre>\n\n<p>The leader key is <code>\\</code> by default, so you can easily cut text by typing <code>\\d</code> or <code>\\D</code>.</p>\n\n<p><strong>Hint 2:</strong> The default timeout for multi-key mappings is pretty short. You might want to increase it to have more time when selecting a register. See <code>:help timeoutlen</code> for details, I\'m using:</p>\n\n<pre><code>set timeout timeoutlen=3000 ttimeoutlen=100\n</code></pre>\n'}, {'answer_id': 32954215, 'author': 'Wayne', 'author_id': 592746, 'author_profile': 'https://Stackoverflow.com/users/592746', 'pm_score': 5, 'selected': False, 'text': '<p>All yank and delete operations write to the unnamed register by default. However, the most recent yank and most recent delete are always stored (separately) in the numbered registers. The register <code>0</code> holds the most recent yank. The registers <code>1-9</code> hold the 9 most recent deletes (with <code>1</code> being the most recent). </p>\n\n<p>In other words, <strong>a delete overwrites the most recent yank in the unnamed register, but it\'s still there in the <code>0</code> register.</strong> The blackhole-register trick (<code>"_dd</code>) mentioned in the other answers works because it prevents overwriting the unnamed register, but it\'s not necessary.</p>\n\n<p>You reference a register using double quotes, so pasting the most recently yanked text can be done like this:</p>\n\n<pre><code>"0p\n</code></pre>\n\n<p>This is an excellent reference:</p>\n\n<ul>\n<li><a href="http://blog.sanctum.geek.nz/advanced-vim-registers/">http://blog.sanctum.geek.nz/advanced-vim-registers/</a></li>\n</ul>\n'}, {'answer_id': 50424088, 'author': 'snap', 'author_id': 8578684, 'author_profile': 'https://Stackoverflow.com/users/8578684', 'pm_score': 1, 'selected': False, 'text': '<p>For those of you who are primary interested of not overwriting the unnamed register when you replace a text via virtual selection and paste.</p>\n\n<p>You could use the following solution which is easy and works best for me:</p>\n\n<p><code>xnoremap &lt;expr&gt; p \'pgv"\'.v:register.\'y\'</code></p>\n\n<p>It\'s from the answers (and comments) here:\n<a href="https://stackoverflow.com/questions/290465/how-to-paste-over-without-overwriting-register">How to paste over without overwriting register</a></p>\n\n<p>It past the selection first, then the selection with the new text is selected again (gv). Now the register which was last used in visual mode (normally the unnamed register but works also side effect free if you use another register for pasting). And then yank the new value to the register again.</p>\n\n<p>PS: If you need a simpler variant which works also with intellj idea plugin vim-simulation you can take this one (downside: overwrite unnamed register even if another register was given for pasting):</p>\n\n<p><code>vnoremap p pgvy</code></p>\n'}, {'answer_id': 52913326, 'author': 'Adrien Vakili', 'author_id': 9033536, 'author_profile': 'https://Stackoverflow.com/users/9033536', 'pm_score': 2, 'selected': False, 'text': '<p>For emacs-evil users, the function <code>(evil-paste-pop)</code> can be triggered after pasting, and cycles through previous entries in the kill-ring. Assuming you bound it to <code>&lt;C-p&gt;</code> (default in Spacemacs), you would hit <code>p</code> followed by as many <code>&lt;C-p&gt;</code> as needed.</p>\n'}, {'answer_id': 53872985, 'author': 'Victoria Stuart', 'author_id': 1904943, 'author_profile': 'https://Stackoverflow.com/users/1904943', 'pm_score': 3, 'selected': False, 'text': '<p>My situation: in <code>Normal</code> mode, when I delete characters using the <code>x</code> keypress, those deletions overwrite my latest register -- complicating edits where I want to delete characters using <code>x</code> and paste something I have in my most recent register (e.g. pasting the same text at two or more places).</p>\n\n<p>I tried the suggestion in the accepted answer (<code>"_d</code>), but it did not work.</p>\n\n<p>However, from the accepted answer/comments at <a href="https://vi.stackexchange.com/questions/122/performing-certain-operations-without-clearing-register">https://vi.stackexchange.com/questions/122/performing-certain-operations-without-clearing-register</a>, I added this to my <code>~/.vimrc</code>, which works (you may have to restart Vim):</p>\n\n<pre><code>nnoremap x "_x\n</code></pre>\n\n<p>That is, I can now do my normal yank (<code>y</code>), delete (<code>d</code>), and paste (<code>p</code>) commands -- and characters I delete using <code>x</code> no longer populate the most recent registers.</p>\n'}, {'answer_id': 58026614, 'author': 'Eduard Kolosovskyi', 'author_id': 5385623, 'author_profile': 'https://Stackoverflow.com/users/5385623', 'pm_score': 2, 'selected': False, 'text': '<p>For those who use JetBrans IDE (PhpStorm, WebStorm, IntelliJ IDEA) with IdeaVim. You may be experiencing problems with remapping like <code>nnoremap d "_d</code> and using it to delete a line <code>dd</code>. Possible solution for you: <code>nnoremap dd "_dd</code> </p>\n\n<p>There are issues on youtrack, please vote for them: \n<a href="https://youtrack.jetbrains.com/issue/VIM-1189" rel="nofollow noreferrer">https://youtrack.jetbrains.com/issue/VIM-1189</a>\n<a href="https://youtrack.jetbrains.com/issue/VIM-1363" rel="nofollow noreferrer">https://youtrack.jetbrains.com/issue/VIM-1363</a></p>\n'}, {'answer_id': 60119781, 'author': 'gregory', 'author_id': 2057509, 'author_profile': 'https://Stackoverflow.com/users/2057509', 'pm_score': 3, 'selected': False, 'text': '<p>Vim\'s occasional preference for complexity over practicality burdens the user with applying registers to copy/delete actions -- when more often than not, one just wants paste what was copied and "forget" what was deleted.  </p>\n\n<p>However, instead of fighting vim\'s complicated registers, make them more convenient: choose a "default" register to store your latest delete. For example, send deletes to the d register (leaving a-c open for ad-hoc usage; d is a nice mnemonic): </p>\n\n<pre><code>nnoremap d "dd           "send latest delete to d register\nnnoremap D "dD           "send latest delete to d register \nnnoremap dd "ddd         "send latest delete to d register\nnnoremap x "_x           "send char deletes to black hole, not worth saving\nnnoremap &lt;leader&gt;p "dp   "paste what was deleted\nnnoremap &lt;leader&gt;P "dP   "paste what was deleted\n</code></pre>\n\n<p>This approach prevents deletes from clobbering yanks BUT doesn\'t forfeit  registering the delete -- one can paste (back) what was deleted instead of losing it in a black hole (as in the accepted answer).  In the example above, this recalling is done with two leader p mappings. A benefit of this approach, is that it gives you the ability to choose what to paste: (a) what was just yanked, or (b) what was just deleted. </p>\n'}, {'answer_id': 61975093, 'author': 'bob', 'author_id': 13603321, 'author_profile': 'https://Stackoverflow.com/users/13603321', 'pm_score': 1, 'selected': False, 'text': '<p>register 0 thru 9 are the latest things you yank or cut etc, and DO NOT include deleted things etc. So if you yank/cut something, it is in register 0 also, even if you say deleted stuff all day after that, register 0 is still the last stuff you yanked/cut.</p>\n<p>yiw #goes to both default register, and register 0</p>\n<h1>it yanks the word the cursor is in</h1>\n<h1>deleted stuff etc will go to default register, but NOT register 0</h1>\n<h1>in standard mode:</h1>\n<p>&quot;0p #put the content of register 0</p>\n<h1>in insert mode:</h1>\n<p>ctrl-r 0 #put the content of register 0</p>\n<p>I also had a friend who always yanked/cut to register x lol.</p>\n'}, {'answer_id': 62951993, 'author': 'mohammadreza berneti', 'author_id': 3464834, 'author_profile': 'https://Stackoverflow.com/users/3464834', 'pm_score': 2, 'selected': False, 'text': '<p>The following vscode setting should allow e.g. dd and dw to become &quot;_dd and &quot;_dw, which work correctly now with our remapper.</p>\n<pre><code>{\n     &quot;vim.normalModeKeyBindingsNonRecursive&quot;: [\n        {\n            &quot;before&quot;: [&quot;d&quot;],\n            &quot;after&quot;: [ &quot;\\&quot;&quot;, &quot;_&quot;, &quot;d&quot; ]\n        }\n    ]\n}\n</code></pre>\n'}, {'answer_id': 64529113, 'author': 'sebtheiler', 'author_id': 10226703, 'author_profile': 'https://Stackoverflow.com/users/10226703', 'pm_score': 0, 'selected': False, 'text': '<p>You can make a simple macro with:\n<code>q&quot;_dwq</code></p>\n<p>Now to delete the next word without overwriting the register, you can use <code>@d</code></p>\n'}, {'answer_id': 64641073, 'author': 'ZhiyuanLck', 'author_id': 9514052, 'author_profile': 'https://Stackoverflow.com/users/9514052', 'pm_score': 0, 'selected': False, 'text': "<p>The main problem is to use <code>p</code> when in visual mode. Following function will recover the content of unnamed register after you paste something in visual mode.</p>\n<pre><code> function! MyPaste(ex)\n  let save_reg = @&quot;\n  let reg = v:register\n  let l:count = v:count1\n  let save_map = maparg('_', 'v', 0, 1)\n  exec 'vnoremap _ '.a:ex\n  exec 'normal gv&quot;'.reg.l:count.'_'\n  call mapset('v', 0, save_map)\n  let @&quot; = save_reg\nendfunction\n\nvmap p :&lt;c-u&gt;call MyPaste('p')&lt;cr&gt;\nvmap P :&lt;c-u&gt;call MyPaste('P')&lt;cr&gt;\n</code></pre>\n<p>Usage is the same as before and the content of register &quot; is not changed.</p>\n"}, {'answer_id': 65785248, 'author': 'Jacob Vanus', 'author_id': 1249891, 'author_profile': 'https://Stackoverflow.com/users/1249891', 'pm_score': 0, 'selected': False, 'text': "<p>I find it easier to yank into the 'p' buffer to begin with.</p>\n<h3>Copy (aka: yank)</h3>\n<pre><code># highlight text you want to copy, then:\n&quot;py\n</code></pre>\n<h3>Paste</h3>\n<pre><code># delete or highlight the text you want to replace, then:\n&quot;pp\n</code></pre>\n<p>Pros (As opposed to deleting into a specific register):</p>\n<ul>\n<li><code>&quot;pp</code> is easy on the fingers</li>\n<li>Not going to accidentally overwrite your paste buffer on delete.</li>\n</ul>\n"}, {'answer_id': 66926326, 'author': 'WalksB', 'author_id': 6382242, 'author_profile': 'https://Stackoverflow.com/users/6382242', 'pm_score': 0, 'selected': False, 'text': '<p><code>noremap mm m</code></p>\n<p>and</p>\n<p><code>noremap mx &quot;_x</code></p>\n<p>is how I deal with it.</p>\n'}]
['https://Stackoverflow.com/questions/54255', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4639/']