Edit a remote file with
vim scp://remote/file
Saving the file with :w
blocks the editor till the file changes are saved to the remote.
I was trying to use :Dispatch :write
to avoid being blocked but that does not work (using tmux or iterm strategy). :Dispatch
is provided by the plugin vim-dispatch.
Relevant internet search results suggest:
set directory=~/.vim/swaps//; set backupdir=~/.vim/backups
The solutions are helpful but require setup of vcs, config files, etc.
I'd prefer
Keeping an ssh tunnel open didn't improve it either.
Update I'd like to know whether there is a solution to run the save process asynchronously. The save process means here, as netrw is showing in the commandline, a scp call to copy the temp file to the remote which can take some time. I'd like to return to my editing in the meanwhile and don't be blocked. I hope this makes my question clearer.
Alternatives to tpope/dispatch are: Shougo/vimproc, idbrii/AsyncCommand, which I haven't tried yet.
It was an old question, yet I encountered the same problem of how to work with remote files efficiently.
My solution is to use unison
to sync files on the fly. A command is defined to call the sync function within vim.
function! s:Sync()
call system("unison -batch /home/user ssh://user@server//home/user")
endfunction
command! Sync :call <SID>Sync()
The speed of sync files using unison is so fast that I don't have much motivation to make it run asynchronously.
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