I am using the latest vim version.
vim --version | head -1
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 12 2019 17:28:55)
Edit a python file with vim.
vim embed.py
x = 3
print(x)
y =4
print(x+y)
Now open a new window with ter
command in vim.
The normal way to execute embed.py
which is in edit status.
:! python3 %
New window open and execute embed.py
.
I have a new idea,how can copy all the lines in embed.py
into the above window opened by ter
command in vim?Show the expected way as below.
ggyG
can't work.
Move cursor in vim window,and press ggyG
.
Move cursor in the python3 window.
ctrl + v
can't work, <C-\><C-N>
can't work too.
It is time to try with gui way,paste nothing also.
Do as Tarun Lalwani say:
step1: copy lines into system clipboard
:%y+
or with other command.
step2: move cursor into the upper window which run python3.
step3: ctrl+v+shift
How can bind all steps with a hot key?
Status 1:
Write the following in my .vimrc.
function! CopyPasteBuffer()
normal gg"+yG
wincmd p
call feedkeys('^W"+')
endfunction
nnoremap <leader>p :call CopyPasteBuffer()<CR>
\p
will put ^W"+
on python3's interactive window.
Status 2:
Write the following in my .vimrc.
function! CopyPasteBuffer()
normal gg"+yG
wincmd p
endfunction
nnoremap <leader>p :call CopyPasteBuffer()<CR>
\p
will move cursor into upper window,now pressing ctrl+v+sfift
can take effect.
Almost done!It remains a issue here.
The last step (step 3) which paste all program's lines into python interactive window haven't been automated into the vimscript,rkta's CopyPasteBuffer()
only bind two steps with hot key \p
successfully.
Please have a try in bash ,instead of zsh.
Almost same result both for normal gg"+yG
and normal gg"*yG
,ctrl+v+shift
or ctrl+w+ctrl+v
or ctrl+v
can't paste content in register *
if it is normal gg"*yG
in CopyPasteBuffer()
(verified in my bash).