I have a vim script I'm developing in my current buffer and I want to execute it. Is there a simple way to do it?
After a long search I have only found two related ways, but not exactly what I'm looking for:
a) "source" command - but to use it I first need to save the content to file and then "source" it back, which doesn't look simple
b) "call" command - but I don't want to call my function, I want to execute the whole file, which defines several functions and has some code outside of functions at all
Use:
:%y" (alternatively: ggyG)
:@"
It will copy whole buffer into default register and then run it.
See :help :y
and :help :@
(and also :help range
maybe).
An autocmd to source the file whenever you save might help:
autocmd BufWritePost <buffer> source %
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