You can use :w to send current buffer to external command.
:w
vim resource.yaml :w kubectl apply -f -