There is a vim function Send_to_Screen(text)
which sends some text to a console screen session. I have a mapping
vmap <F4> "ry :call Send_to_Screen(@r)<CR>
which calls the function with the current selection. Now I want do define another mapping which calls the function with the contents of the whole buffer, but I don't get it to work. I tried
nmap <F5> maggVG"ry`a :call Send_to_Screen(@r)<CR>
but it doesn't work. So how do I define the mapping with the text of the current buffer?
How about:
nmap <F5> :call Send_to_Screen(join(getline(1,'$'), "\n"))<CR>
The function getline()
returns a list of lines in the selected range (1 is the first line and "$" is the last) and the function join()
joins the contents of a list together with the provided separator ("\n" in this case). See:
:help getline()
:help join()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With