UPDATED: bash script now even more cool!
There’s a feature in vim of editing files over scp, built in since vim 7.1 (originially the now baked in netrw plugin).
This feature uses scp to copy a local version of the remote file over scp, edit it with vim, and with each save connect via scp and save it to the remote location.
This allows you to edit remote files with your own tailored vim instance (plugin galore!).
The problem is the connection is not reused, and it’s really slow when vim (scp) connects for each write.
To solve that, save this script and
chmod a+x it..
This script opens a ssh connection without running any command in the background using
ssh -f -N.
Then the script calls vim with the wanted path to edit, and finally kills the background ssh process when you’re done editing.
And you’re editing remote files with vim blazing fast..