Coming Home to Vim (2010)
stevelosh.com
stevelosh.com
Cuteness aside: for all the awesomeness that a tailored vim setup provides, I haven't been able to keep one stable since a decade ago, when I used an ubuntu desktop for work. Maybe I'm just getting old, but Helix's batteries-included approach to reimplementing vim has resulted in a much better experience for me in practice, even though it's lost me some features in theory (I miss you, vim-fugitive!).
And my hands can't even tell it's not vim…mostly!
How? Helix is <noun> → <verb> whereas Vim is <verb> → <noun>. I'm used to deleting entire sentences using `das`, but the order is completely the opposite in Helix.
Edits much simpler than that are often the same keystrokes as vim (`A`, `C`, `.`, `/`, etc), and those much more complicated would have kicked me into visual mode anyway.
I like the idea of using "<motion><verb>" instead of "<verb><motion>".
Though, when I was first trying it out, enough of helix's keybindings conflicted (or were different).. it definitely takes a bit of effort to adjust. (e.g. I like vim's `$` to go to the end of line, but helix uses this for "filter through shell command". Helix uses gh/gs/gl instead of 0/^/$; which is arguably nicer).
What? Our cursor matches the default vim one (always 1-width, always bar). If you want to change cursor shapes, there's a config option too https://github.com/helix-editor/helix/wiki/FAQ#change-cursor...
* The how-to-use and keybindings, while weird, are going to stick around for another 40 years and probably outlive me!
* Support for languages as good as VSCode
* It is fast
* It can load, search and navigate big files (e.g. 1Gb) quite easily, which most non-text editors seem to struggle with (Notepad++, VSCode, etc.)
This is also the reasons I am learning to use tmux, even when using Windows. Just feel it is a good investment, it is nice to use and scriptable.
What puts me off is getting the muscle memory to feel productive!
Oh come on now that's can't even be close. Surely vim supports and order of magnitude more languages than vscode at least. I actually haven't found one without vim support yet, including a dozen assembly languages, verilog & vhdl, various horrible proprietary scripting languages and so on.
Does vscode use vim syntax and script files to try and match that or something?
Vs code supports language server protocol [1] and also includes support for syntax highlighting [2]
If I recall correctly, vim supports syntax highlighting through less-than-elegant regex searches.
[1] https://code.visualstudio.com/api/language-extensions/langua...
[2] https://code.visualstudio.com/api/language-extensions/syntax...
Treesitter, also built-in to Neovim, provides semantic syntax highlighting, just like an IDE.
And Vim can use LSP using a plug-in like Coc.
What %ge of languages supported by vim are actually supported by microsoft - or "the microsoft community?"
Today VS Code also allows for Language Server processes to entirely delegate syntax highlighting as well, if you do need a very custom turing-complete tokenizer. (More accurately, it is included so that Language Servers can share the tokenizer work they are already doing as part of their parsing and processing efforts rather than duplicate that effort in a TextMate Grammar.)
Wrapping a TextMate Grammar in a VS Code extension is one of the easiest types of extension to build for VS Code, it's just the grammar JSON file and a couple lines added to an appropriate package.json file added to a ZIP file that then ostensibly resembles an npm package.
Deeper projects such as Language Servers start to get complicated quickly, but also are where a lot of power that VS Code has that vim is starting to import the other direction: many neovim users rely on Language Servers ostensibly built for VS Code first for an increasing number of language features.
[1] https://code.visualstudio.com/api/language-extensions/syntax...
I miss VIM, I really do, but I really only use it these days if I need to ad-hoc modify an individual file while I'm in a terminal somewhere.
https://marketplace.visualstudio.com/items?itemName=asvetlia...
Admittedly it's been a while since I tried vscode, but when I did my experience was that vim's functionality is a superset of what's available in the plugin. Especially if you learned on the plugin, vim would generally work the same as vscode.
The issue was the other way--there was functionality missing in the plugin, or sometimes when you tried to compose more complex operations they didn't work or worked strangely, etc.
Like, if you're used to working in C you won't see the advantage of a C++ compiler, but if you've spent 15 years working in C++, you're gonna feel pretty hamstrung by a C compiler.
imap/nmap don't seem to work -- I think I'm an intermediary vim user in the sense that I don't have all the shortcuts memorized. So it can be useful to just throw together a macro to encode an idea like "change the parentheses to brackets around this variable and then go to the next search result."
I'm sure there's a built-in command for this sort of thing but I don't have it memorized, so what I'll sometimes do is just perform the transformation manually once, keep track of which keys I hit, and then nmap that to some random key.
Before, my gripe was that visual mode didn't work, but they added that (yay!).
VSCodeVim seems to support q-macros just fine. The lone silly missing bit is that VSCodeVim makes it slightly tougher to save/reuse q-macros than proper Vim [1]. In Vim those letters are the exact same "registers" as copy/paste so that you can record a macro to register 'a' with `qa…<Esc>q` and then if you want to save that macro for later you can just paste it into a document somewhere `"a` (paste register a) and pull the macro back in with the right motion and yank to the register you want (`<motion>ya`). VSCodeVim unfortunately uses separate registers for now and it is a bit more work to save/restore q-macros.
Unfortunately before hearing about them I mapped qq to 'quit' and I'm afraid the muscle memory is just stuck there now.
When I was an intermediate user of vim for several years I had drastically custom mappings because I thought I knew enough and knew better. I thought I had a good excuse, too: I was using a different keyboard layout and I might as well remap everything.
As an aged user of vim, I can't call myself "advanced" or an "expert" user I don't think, I've returned to the wisdom of the sages: avoid custom mappings. I still need some moderate remappings for my keyboard layout but have come back around to "the less I remap, the better".
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.Is copying .vimrc whenever logging in for the first time too much work?
Computers are perfect automation machines. Why embrace useless toil?
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
Coming Home to Vim - https://news.ycombinator.com/item?id=4218575 - July 2012 (118 comments)
Coming Home to Vim - https://news.ycombinator.com/item?id=1710702 - Sept 2010 (121 comments)
Coming home to Vim - https://news.ycombinator.com/item?id=1619544 - Aug 2010 (34 comments)
* Coming home to Vim* - https://news.ycombinator.com/item?id=329525 - Oct 2008 (12 comments)
However, these things can be replicated with Vim emulation. What is the benefit of using Vim proper these days?
Not that much, objectively. Many people enjoy its low resource usage, but most developers use machines perfectly comfortable with VSCode & Jetbrains. There's the startup time, which I don't really see as an issue for other than quick ad hoc file edits. Some people just like to stay in the terminal. It's mostly a matter of individual taste/preference.
The one thing I would point to as a real (if minor) benefit is the UX consistency - since everything is a buffer, keybindings are the same for plugin-enhanced UI elements as they are in regular file buffers. Even though I'm an nvim user, tbh I'd much rather have a true GUI, if they had been better and more consistently designed.
I have used emacs, IntelliJ, VSCode etc in the past (some for lengthy periods). I settled on nvim, not because it's particularly superior (and I'd prefer to ditch the terminal legacy), but just for the sake of settling on one thing I get to know well, and that I'm pretty sure will be around for longer than I will be. I have other things I'd like to spend my attention budget on.
Depending on what you're doing, the native vim plugins might well be vastly better. I swear by YouCompleteMe as a wrapper for clang-complete for navigation of a C codebase. The autocompletion is pretty good too. I Haven't seen anything better with any other editor/ide vim key bindings or not.
I'm sure if you work hard enough at your s-exepression configs emacs can be as good if those are the keybindings you know and love. But why look elsewhere? <- Not rhetorical, genuine question - have you found a reason?
I don't know what I don't know, so that's why I ask. My JetBrains IDE does so much out of the box, I figure people give up all these features for a reason. Beyond vanity and too much free time, of course.
But I've also never tried to use vim as a java ide and it could be great for all i know..?
That's exactly what I don't like about it. I'm a simple guy; I like simple editors. I will spend more time turning off things in JetBrains and VSCode that I find distracting and annoying than I will spend on setting up Vim to add some features I want like LSP support.
If I'm in the command line and I want to edit a text file, VS Code takes 4 seconds. Neovim takes 400ms. I installed vim-polyglot and it has syntax highlighting for even weird config files. I don't understand why no one is competitive with Vim by these metrics.
- That said, I do love the keybindings, and I've not found a single vim emulation that doesn't feel wrong within a few minutes of usage. It's very, very difficult to get a realistic vim emulation mode, to the point that I'd rather not try to use it in another editor
1. Editing files on machines, where you can't use vscode remote editing.
2. Leetcode grinding. Many companies allow only vi for onsite interviews. Some companies will prevent you from using features of vi like ctrl-n and macros. So might want to practice with the bare minimal feature set.
3. General text heavy lifting, if you are aware of how to use Macros.
I used vim because it was installed by default on just about every modern Linux server, so as an admin it was much simpler to just use vi (less easy to fat-finger a config file due to the modal).
But I wasn't porting my personal config around 100's of Linux servers, unless when absolutely necessary [not every admin wants the same config].
As far as having a huge ecosystem with vi - has anyone actually done a comparison of number of 'things' that make up an ecosystem and active users between VSC, emacs, vi?
I know reddit isn't a good sample size, but looking at subbed users:
- vscode 95k - vi 151k - emacs 62k
I'm not doubting that vi would have the larger community, but I'd have expected emacs to be larger than vscode on reddit but it is not.
I daresay that most nano users use nano like a "glorified nano" too. I wouldn't blame nano for this.
Nano can actually be a pretty slick little editor if you're willing to dive a bit deeper.
Jetbrains actively forces developers to avoid the terminal for vendor lock-in.
Microsoft, ha. Embrace, extend, extinguish, (first Python, now Copilot) isn't new.
Sadly, commercial software turns success into "selfish dark patterns," at the drop of a hat.
I've an extremely strong urge to go to Vim.
The quantity of work won't be small however. Setting up graphical debugging, refactoring, inheritance visualization, will be an enormous mountain.
I'm not sure I'll ever use Vim for JVM languages. JVM languages lend themselves to enormous complexity.
Likely because the IDE enables it.
It's unfortunate; I still see people confused by it today.
Prior to that I was just another developer googling "how do I quit vi."
Also, his .vimrc file is epic. It’s a little dated now but it shows how deeply Vim can be customized, in ways that most editors cannot.
edit: i also keep the binding as close as vim's vanilla as possible. and that's it.