by amelius · 4y ago · 0 comments
1. When opening a file that is already open in another editor in another terminal, Vim gives me many options, but it doesn't give me the option to kill the other process (or ask that process to save its buffer and exit).
2. My .vimrc should really follow me around automatically. Too often I find myself installing a new machine and missing my settings. I don't know how it should be implemented, but this is something that should work. Edit: if SSH can pass the DISPLAY variable around, then it could do the same with (a key to) .vimrc. Once a .vimrc is associated with an account, it will stay there, so if I log into the machine from the console, I should have my .vimrc (this also happens to the .Xauthority file, although less useful). This could also apply to other settings, of course. And it would be even better if my Vim binary followed me around too, but this is perhaps too futuristic.
Invoke your local editor and edit the remote file. Additional benefits: no lag or delay in your buffer and editor, and you can save locally should the remote session crash.
(This presumes a direct SSH connection, e.g., no bastion host, though that can be addressed via tunnelled connections.)
git clone https://my-dotfile-repo
ln my-dotfile-repo/.vimrc ~/.vimrc
Done.This doesn’t hold true in 2022. People expect their settings to follow them around automatically.
One could make a command to check some central registry (or, what the hell, maybe a .vimrc blockchain) but typing that command would be about as much work as the curl/wget/git solutions proposed elsewhere.
So it’s Vim’s fault because you don’t know how to sync your dotfiles?
Depending on your setup, there many solutions to this problem.
Start here: https://dotfiles.github.io/
Something like that would be a bit better than what I'm doing now, which is just keeping a dotfiles repo that lives on github. Since password authentication is no longer allowed, and I need certain config stuff in there to stay relatively private, I have to do the public key dance to get started. The one benefit there is allowing diverging changes on different machines, and good control of what you push back to the store.
Now that I think of it, maybe I should put it on my website so I can curl it onto a server if there is no git available.
One potential risk with that is that it looks just at PID files, which may or may not be Vim. If you have a left-over swap file from a week ago after a reboot with PID 666, that PID can now be anything (including another unrelated Vim process!) It's actually kind of tricky to implement that reliably.
That said, you can probably implement something like that through the SwapExists autocmd.
Your second point seems more like some system design issue rather than a Vim issue per se. The problem also exists for your zshrc, tmux.conf, htoprc, and lots of other things. I don't think it's something Vim really needs to solve, but rather the system.
https://github.com/Aperocky/unix-setup
I had to do it several times over the years, even have a shell file that would install all the plugins straight from git. The process take no more than 5 minutes and I'm right at home in the terminal of the new machine.
Incidentally, I just polished my script for working around that issue: https://github.com/fiddlerwoaroof/dotfiles/blob/master/scrip...
Maybe minified, portable vimrc but even then, it makes me wonder, why not just copy all your dot files for your user?
vim scp://user@myserver[:port]//path/to/file.txt