nno <silent> p @=<sid>CustomPaste(v:true)<cr>
nno <silent> P @=<sid>CustomPaste(v:false)<cr>
fu s:CustomPaste(below) abort
let register_size = strchars(getreg(v:register), v:true)
if register_size > 10000
let question = 'You are about to paste a long register. Do you want to proceed? y/n'
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! | 20put! | 10put!
Or use :g with a pattern matching line numbers:
:5 yank | :g/\v%10l|%20l|%30l|%40l|%50l/ put!
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 show off some interesting features of Vim that readers might want to use in other scenarios.
Using :normal edits
5,7 # On ...
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 linewise. There is note at :help setreg() which hints at this:
Note: you may not reliably restore register value
without using the third argument to getreg() as ...
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 "another unneeded mapping(s)". So I'd rather suggest you to re-think your copy process, not to re-design paste process, as this:
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](destination) as html <a> elements, etc...
It can't keep the font size when you can only have one font size in a buffer
It can't keep the colors and the font ...
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 example working with your initial diagram.
Start by using a visual selection to copy the first router on the top left corner. First move to the upper left +, ...
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 is now back to normal. Whew!
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:
'<,'>w >> b | '<,'> d
Edit To address the questions in comments:
If the file you're trying to write doesn't exist you can use w! to force the ...
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 the second block, it should work.
To move the first paragraph to before the second paragraph you can do:
vip # Visually ...
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 mode and 'paste' unset.
If you don't want to use bracketed paste mode (which you implied in your answer by calling it a "workaround"), and would prefer to use ...
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 0 0 ~ is added as a prefix, and ANSI escape sequence ESC [ 2 0 1 ~ is added as a suffix. It will send the text with the prefix and the suffix to whatever ...
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 problem by
:mapclear | mapclear <buffer> | mapclear! | mapclear! <buffer> to remove all mappings.
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:
if [ -z "$(vim --serverlist)" ]; then
xterm -name vimserver -xrm 'vimserver*vt100.Translations:#override\
Shift <KeyPress> Insert: insert-selection(None,None)' \
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 in version 8.1.1779, but ISTR that in earlier versions pasting did not work; just like you describe. This might have been changed with 8.0.140, but I can't check ...
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 opfunc to s:func, i
" have to use a func argument.
" In function scope of normal map, v:register won't be changed by ex
" command (except :normal) ?
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(getregtype(), 0, 1) . '`]'
With this you can visually select the text you have just pasted (or changed).
Note that gp is already used by Vim for
Just like "...