Hot answers tagged

6 votes
Accepted

Is it possible for Vim to confirm before pasting huge amount of text?

Try this: nno <silent> p @=<sid>CustomPaste(v:true)<cr> nno <silent> P @=<sid>CustomPaste(v:false)<cr> fu s:CustomPaste(below) abort let register_size = ...
  • 5,547
6 votes
Accepted

Paste append multiple lines

This would be very easy with a macro, but you've stated don't want to use one, so here's a few alternative methods. I think they're all more complicated than a simple macro-based solution, but they ...
  • 28.9k
5 votes

Paste append multiple lines

I am going to suggest using Ctrl + v (<C-v>) to make a block. It sounds as if putting the second block after the first doesn't do what you want. However, if you put the first block in front of ...
  • 236
5 votes
Accepted

Yank once then multiple paste

You can use the :put command (well :put! for P). One problem would be that the line numbers will change as you paste additional lines, so: Work in reverse order: :5 yank | 50put! | 40put! | 30put! | ...
  • 24k
5 votes
Accepted

Paste not working

For some reason, editing _vimrc in the Vim file wasn't working. From within vim, if I used :e! $MYVIMRC to change the file, everything worked out. I removed set clipboard=unnamedplus and the behavior ...
  • 221
4 votes
Accepted

Inline paste from System Clipboard

Normal "put" does not add a newline of its own. If you get it then you've yanked it earlier. Actually, it's not too hard to trim stuff from the register, it's rather a problem of "...
  • 17.9k
4 votes
Accepted

Pasting modified register contents into Visual Block selection

To modify the content of a register while keeping its type (characterwise, linewise or block) you need to use setreg(). Otherwise Vim is only able to choose the register type as characterwise or ...
3 votes

How to paste rich-text in GVim

The simple answer is no, it's not possible. Vim is a text editor which handles text files: It can't decide how to keep the formatting of e.g links: Is it supposed to past them as markdown [link](...
  • 46.8k
3 votes
Accepted

vim - how do I cut some lines of file-1 to file-2 in 1 step?

You could make it a one liner using a range: 2,3w >> b | 2,3d And if you want to keep doing this with visual selection, you can select the lines and then use '< and '> for the range: '&...
  • 46.8k
3 votes
Accepted

Need a functionality behaving like Replace on text but for Pasting Blocks

Visual block mode (which you can enter with CTRL-V) is perfect for this kind of usage. You can copy and paste squares much like your router boxes and you can do so without shifting columns. Here is an ...
  • 26.5k
3 votes
Accepted

How to paste copied character in ex mode?

You can use Ctrl+R, " to insert the contents of the default register into the Ex command line. The default register is where what you just yanked will be. See :help c_CTRL-R for details.
  • 26.5k
2 votes
Accepted

Why does <F22> appear when pasting into Vim?

This turned out to be caused by Vim inserting text because of the escape sequences sent as part of bracketed paste mode. The solution is simply to paste directly into your terminal with Vim in normal ...
  • 28.9k
2 votes

Why does <F22> appear when pasting into Vim?

Thanks to a hint from Rich, I found a workaround. Many terminal emulators (such GNOME Terminal) support bracketed paste mode. When you paste text in these terminals, the ANSI escape sequence ESC [ 2 ...
  • 1,704
2 votes
Accepted

Paste register contents from :reg screen

You can use :normal[!] to run normal-mode commands after pressing :, which should keep the output from :registers/:display present. For example: :normal! "rp pastes from the r register. Elide the ...
  • 21.8k
1 vote

How to paste rich-text in GVim

Copying ZyX's answer from SO. Temporary adding html to clipboard option should help: set clipboard^=html put + set clipboard-=html :help clipboard-html: When the clipboard contains HTML, use this ...
1 vote
Accepted

Can't type <>[]{}'"()` and backspace in vim after :set nopaste

I found that it was that the coc.nvim caused the problem. :verbose map <BS> shows my <BS> is mapped to coc#_insert_key('request', 'a-very-long-string') because of coc.nvim. I solved my ...
1 vote
Accepted

Disable Shift+Insert from pasting from Primary

I found a solution which relies on Vim's +clientserver capability. It just took a small addition to a script I already used. The final result is this vimserver.sh: #!/bin/sh if [ -z "$(vim --...
  • 2,267
1 vote
Accepted

How to paste yanked text over visual selection?

Pasting over a visual selection should work exactly once. When pasting a second time the visual selection from the first time will be pasted instead of the yanked text. (At least that's what happens ...
1 vote
Accepted

Can I select and paste with a single operation?

A custom operator that select and paste from any register: nnoremap ,p :call <sid>opfunc_reg("<sid>select_and_paste")<cr> " Apply current register to g@ . It's not allowed to set ...
  • 5,968
1 vote

Multiline paste with relative columns alignment

AFAIK, there is no direct way to do that in Vim. Here is a workaround: First of all I have the following mapping in my vimrc (From Vim Tips Wiki, Tip 759): nnoremap <expr> gp '`[' . strpart(...
  • 8,715
1 vote

tabs after pastetoggle instead of spaces

Yes, you have to. To make it easier, you could add the following snippet to your vimrc: set pastetoggle=<F9> noremap <F9> :set invpaste paste?<CR> inoremap <F9> <C-O&...
  • 8,715

Only top scored, non community-wiki answers of a minimum length are eligible