There are several different ways vim can be used to edit remote files,
rclone
you can use caching to enjoy zero latency. But rclone mount
is a bit buggy overall.sshfs
you will still suffer from latencyNow after reading vim documentation I have found the fourth way. There is actually built-in plugin in vim called netrw
that can be used to edit remote files directly. For me zero-latency is very important, and it also solves the unstable problem that rclone mount
has.
According to their documentation you need to have set nocompatible
and filetype plugin on
in your .vimrc
file. (Actually this might not be necessary).
Then you can open a remote file with vim scp://user@host/path/to/file
. For example, for editing notes on asukachan.com I used
nvim scp://Asuka//opt/asukachan/notes/
And I will be able to see the directory structures. The common options you will need are
Enter
to open a file or directoryo
to open a file in a new windowv
to open a file in a vertical splitt
to open a file in a new tabd
to create a new directory%
to create a new fileYou can also use :help netrw
to see more options owo, the documentation is actually worth looking at!
You can put an alias in you ~/.bashrc
file that makes editing note even easier
alias notes=nvim scp://Asuka//opt/asukachan/notes/
So you can easily launch the editor with remote connection.