Prelude
I used ViM'om and was pleased. Once I found out that he, to all his might, knows how to be a small file system guide (note, just run
vim. ). Later I discovered that it is much more convenient to do this by adding the
NERD_Tree plugin - it is really convenient and I would be happy if VimCommander was made based on it, however Leandro (by VimCommander) went the other way and tried to imitate MidnightCommander. Well, it is necessary to teach VC to work with remote systems via ssh, I decided, because his older brother (mc) is doing quite well. Approximately with such thoughts, I opened the shell and typed vim ~ / .vim / plugin / vimcommander.vim.
Ideas
I didn’t have any desire or opportunity to implement such functionality on a pure ssh client, but then I remembered one utility -
sshfs ...
My thoughts, as always, did not go from design to implementation, but vice versa (and what to do) ...
The first thing I had to think of, or rather to collect from existing experience, was the command syntax and how it is more convenient to call it. Working through sshfs was convenient in that I didn’t have to parse the ~ / .ssh / config file in case the user has aliases there, the utility does everything itself, as it should be.
The syntax for entering the address was plain:
[IdentityFile,] [UserName @] HostName [: Port] . Of course, some effort was worth checking and parsing the string to connect to, what would be the most competently to feed it to sshfs (why do we need extra errors?).
')
It was decided to call all this stuff more or less by analogy with the MC
F9 key (you still have to save the ideology of the author VimCommander, who took all the hot keys from there). The rich menu there, of course, will not come out, but my function will be called :-). And ask a couple of questions. What kind of questions could you think? However, they play a very important role here.
Work logic
The first thing you need to understand is that the connection itself does not fall off, when you close VimCommander and even all copies of ViM (in MC everything will be broken when exiting). As a result, we get the first question from the wizard:
What are you want to do (mount / dismount / abort) sshfs? [mda]:. And so, everything that was mounted must be disconnected by itself (rebooting the machine, of course, will
save the father of Russian democracy solve the problem, but how often do you rebuild your car?).
Here we will enter a little bit into the architecture: everything that is currently mounted is written to the
/tmp/ssh_dir.list file. The mount points, by the way, are created in the same place - in
/ tmp / , with a random name (thanks to / dev / urandom). It turns out that you can work with the remote system, exit ViM and return to work after some time, and not mount the remote system again.
The unmounting issue is also not wise:
Choose which mount point you want to dismont: /tmp/CEc6CgFeRE0U(192.168.0.1);/tmp/4BEK8QqtWqWT(habrahabr.ru) . You just need to specify the sequence number of the host that is no longer interested.

The modified text of the vimcommander.vim script is attached (there are still minor changes to other functions inside, so who can only take the described function (roll back to the commit in question), the remaining changes when I describe them separately).
What is missing
1. MB would be worth adding a function to unmount everything.
2. It may not interfere with the list of mounted hosts, although it can be seen through dismount.
3. Also, the code and "invitations" are far from perfect ...
PS There are other things that I lack in VimCommander, there will be time to concoct them.
The main thing is to enjoy working in ViM.
All changes were uploaded at the request of Leandro Penz (author of VimCommander) on GitHub, I hope that he will be able to use them with his branch.
My fork:
github.com/Alukardd/vimcommanderMain project:
github.com/lpenz/vimcommanderScript page:
www.vim.org/scripts/script.php?script_id=808UPD: I did a little code refactoring, at the same time I fixed a couple of bugs.
Just a small note: sshfs works via sftp protocol, so it should be active on the server side.