since there are quite some comments highlighting the effectiveness of a good VIM setup and muscle memory of 10+ years, I would like to know your opinion on starting to get into it now (end of 2022).
For context: I'm a backend developer with 10+ years of experience, mostly using Java IDEs, and lately some vscode (for go, typescript, rust). I have some knowledge in vim, and can use it for basic text editing, but I still use the arrows for navigation, and found the "hjkl" navigation difficult. I'm somewhat experienced using linux and the terminal, and would be curious to dig deeper into more terminal-based workflows.
The question is: do you think it's worth the effort to learn using VIM more deeply today? The goal would be to at least be able to do the go and rust coding in vim, it doesn't need to be a full Java IDE. Bonus points for an opinion about "If yes, do you think VIM is still fine, or rather neovim? Or something fresh like helix?"
Thanks a lot!
Learning enough Vim for it to pay off in terms of productivity and whatnot is quite a journey. If you are committed, it might take a couple months to follow chapters 1-12 and 20-32 of the user manual, which will put you in a better position than most Vim users. If your goal is really to be able to use Vim for Go and Rust projects, then there is no way around that first step, but if you somehow don't go all the way, then what you have learned will surely come handy next time you have to use Vim so there is no loss, here.
> do you think it's worth the effort to learn using VIM more deeply today?
I did that and I really love where I am. Will it click for you? I have no idea.
> If yes, do you think VIM is still fine, or rather neovim? Or something fresh like helix?
- Vim (not VIM) has been in active development since 1991 and it is not showing signs of slowing down. It is more than fine.
- Neovim is merely a fork with different goals. At a low level, the two tend to diverge more and more but when it comes to the core user-facing stuff like Ex commands, modes, operators, motions, etc. there is practically no difference.
- Helix seems promising but it is far less ubiquitous than Vim.
Everything is worth learning, whether you have an immediate use for it or not.
Once this basic-but-crucial skill level is mastered, using vim more proficientely as a daily driver is entirely a matter of taste. Personally I prefer using a fully-fledged IDE for anything that goes beyond a simple script.
Nowadays I just use a GUI, and only use vi for editing config files and the odd program on a remote system. But even that's being supplanted by editors with remote capabilities.
It's absolutely worth it to learn enough basics to edit files. Beyond that, only if you really dig the editor.
In my opinion, Vim/Emacs are the best way to make that interface as easy to operate as possible, since it completely removes the mouse from the equation. Along those same lines, I felt so much liberated after switching to i3, insomuch that I try to replicate the experience on MacOS, after switching over for work.
EDIT: Also, the obligatory "You don't grok vi" SO answer: https://stackoverflow.com/questions/1218390/what-is-your-mos...
I live in a terminal except for the browser. Of course my xterm bindings are always vi-mode and tmux too. I have key bindings to unite all my i3/tmux/vim 'getting-around' keys and also fought that fight to unite the clipboards, even across VMs etc.
Getting back to why I say 'no' is because once you're used to the modal, and getting around with the usual vim motion keys, it makes using anything else near impossible and clumsy. I have great difficulty composing text in browser (like right now) and also emails, etc. And if any editor online allows vim keybindings, you must make sure that you are used to defaults otherwise the vim-mode won't do you much good. Like escaping with CTRL-[, or delete word with CTRL-W, which closes the tab in the browser (firefox and chrome and I never found a way to turn that off, so I lose a lot of work that way). For instance godbolt and leetcode both had vi-modes but there's enough of a difference, even though I try to use nearly all defaults, that I still end up composing any code/english in another terminal window.
I am completely hopeless using a mouse or arrow keys. If I have to go to on-site interview and have to use something other than vim, well it makes me look like I haven't sat down at a computer in 15 years. I am a hostage now to my habits and am very wary of hopping over to VSCode/CLion/jetbrains whatever else because I will be a fish out of water.
The work-issued machine may run windows or macos, but my dev environment always matches the testing/production environment and that's linux (usually ubuntu).
I always have several terminals open for git, docker, tailing logs, watch scripts, etc. Vim is really the only sensible option for editing configuration, writing git commit messages, _viewing logs_ ... can't stress that last one enough. What are you going to do when you need to do more than just grep a single log file? You need an editor that doesn't blow up opening massive files.
Yes it's absolutely worth knowing. Everyone who uses it needs it and everyone who doesn't eventually will.
I would go with neovim over vim nowadays, and if you want something more familiar that will get you up and running more quickly, try AstroNvim [0]. Later on, if you also like to tinker, you can set it all up just the way you like it.
I've heard of vim being called a PDE (personalized DE) [1], and I think that makes a lot of sense.
Here are some reasons why I use it:
- it's fast
- works consistently well over SSH/in docker containers/remote
- can use it pretty much everywhere and if it's not installed it's easy to setup
- awesome for doing quick text edits or text manipulation (I prefer Vim to sed/awk or anything else)
I don't Vim as an IDE replacement since I find it just takes too much time to maintain a working setup. I'm also not a fan of addons/plugins as over time they tend to fall apart.
Disclaimer: I don't often use a modal text-editor like vi/vim, I use one like emacs that employs control-codes. ('jstar', a clone of the WordStar that I've been imprinted with for nearly 40 years)
All UNIX systems have vi/vim built-in. It pays to have a working knowledge of it, even when it's not your everyday text editor. It's got me out of a few emergencies with recent installs over the years. (Broken /etc/fstab, anyone?)
https://www.barbarianmeetscoding.com/boost-your-coding-fu-wi...
Core pitch:
> You may be wondering... Ok. If Vim is so good then... Why not just use Vim instead of Vim inside Visual Studio Code?
> Great question! The truth is that setting Vim to work with a feature set similar to modern text editors is not a trivial task. Features likes code completion, code navigation, in-editor error messages, etc, although supported by Vim don't work perfectly out of the box.
> Visual Studio Code and Vim together offer a very sweet spot that balance the ease of setup and super rich development user experience of Visual Studio Code with lots of the amazing features present in Vim.
> The translation is not yet perfect though. And if you're an experienced Vim user you may find some features missing. But all in all, VSCodeVim offers a very pleasant Vim experience outside of Vim.
What I really like in Vim is not Vim itself, but modal editing, mouse-free navigation, staying at the home row. Ideally I would like this model to be universally available across my environment. Like MacVim but everywhere. Plus, a trackpoint at the home row (really loved IBM ThinkPad).
Home row is great but it's so much addictive that you want it everywhere, but I still haven't found a universal way. I bought a UHK[1] and learn how to use it and Karabiner elements complex modifications.
Also these days I tend to think that physical navigation (characters, words, lines, paragraphs…) is really not what I should think about when working. So lately I've been exploring helix and projectional[2] (structural[3]) editors.
My younger colleagues are sometimes so awkward in terminal so I've been thinking about investing some time into setting up a well tuned and documented shell environment for them somewhere. I think I'd start with this awesome article[4].
[1] https://ultimatehackingkeyboard.com/ [2] https://www.alexeyshmalko.com/20200830010958/ [3] https://github.com/yairchu/awesome-structure-editors [4] https://www.masteringemacs.org/article/keyboard-shortcuts-ev...
I think its well worth it. Even for the macros, normal commands there is no more efficient way to edit text.
If all touch keyboards had vim-mode we'd all be more productive on smartphones. People who use vim over ssh on mobile devices knows this. I've remapped the record macro (q) to (qq) on mobile devices and put my normal-mode leader key on q, it works really well.
As for the second question, differences between regular vim and neovim largely don't matter for learning vim, as the bulk of the changes is behind the scenes. Some plugins will depend on a specific vim version, but your muscle memory probably won't.
> since there are quite some comments highlighting the effectiveness of a good VIM setup and muscle memory of 10+ years, I would like to know your opinion on starting to get into it now (end of 2022)
I think this is not a good mindset to have. Knowing what's effective and building that muscle memory will take a long* time. If you approach thinking that "this is going to make my productivity fly because other people said so," the learning curve will flatten you and make you sad.
IMO, do it for curiosity's sake - having a hacker's mindset in the beginning will smooth that curve out!
As a testimonial mirroring other comments in this thread: you really can't go wrong with it once you get the hang of it. My experience with vim has been always positive & I've never had to change the core of my config for years. 99% of every LoC I've written in the past 10 years has been in vim. Every time I had to use/try a new editor, vim keybinding is the first extension I install (or setting I enable). It has helped my RSI a bunch (huge QoL improvement) and this is especially crucial with laptops: no more trackpad fiddling in the middle of typing!
(yes Neovim supports mouse, don't @ me lol)
I started with Vim because of the modal editing (prompted by the classic in-person witnessing of a Vim user). I had just switched to the Workman KB layout so I was already slow and useless - why not be slow and useless for a while, but then have also learned Vim? I started out with the modal emulation in various editors, provided by extensions, but over the years I became more and more sick of Windows' BS and swapped to Linux for dev. This is when I encountered Neovim, and I now realise Vim is so much more than the modal editing.
As I wrote in another comment, working in code now without Vim feels like punching in a dream. I won't say I'll never leave Vim, but until there's something that allows editing as ergonomic as Vim's, startup as fast as Vim's, terminal/GUI options like Vim has, integration with basically anything like Vim can, and a lack of Big-Tech-BS like Vim has, then I'll probably just keep using it.
It took me some hours over a few weeks to get my neovim config going but once I did and got accustomed to the keybinds, I definitely found the time investment worth it. Especially for the decreased pain I feel in my hands and I don't have to move around as much.
If you need some help getting a neovim config going, Chris@machine has this very helpful YouTube series called neovim from scratch, which goes through some of the common neovim plugins and details a config in Lua. Gl :)
https://www.youtube.com/playlist?list=PLhoH5vyxr6Qq41NFL4Gvh...
Only worth it on four conditions:
1. You are able to incorporate it into the tools you need - whether than be an IDE, a workflow that involves actually opening VIM, or whatever.
2. You stick with it, because the costs in terms of time and effort are big up front while the benefits start very slowly but build up later and faster with proficiency.
3. You aren't already using a good text editor or IDE that provides the benefits you're looking for. For example, the weird "hjkl" navigation is actually part of a bigger feature set that will run circles around basic arrow- and page-key navigation and editing (even with an IDE). But, if you're looking to benefit from regex features, why even most basic IDEs usually have that.
4. You have adequate muscle memory. You won't be fast and you won't gain proficiency if your fingers won't remember those keys and combinations.
...seems like a cautionary tale so far, so let me temper by saying I install wherever I can - including IDE plugins, etc. Microsoft (VS and Code) and JetBrains IDEs both have pretty decent plugins. I can say without boasting that I am faster with it at both pounding out text and editing text from all sorts of crazy languages and environments. And often times it gives me a speed advantage over my peers who don't use it. But that's only because I took time to become proficient at it and learn some of the tricks that are available.
> do you think VIM is still fine, or rather neovim? Or something fresh like helix?
VIM is fine in terms of stayability - it's not going anywhere. I'd say look at the alternatives only if you're interested in the special benefits they have over normal VIM.
Vim package suggestions:
scrooloose/nerdtree - File tree navigation. jeetsukumaran/vim-buffergator - Work in buffers instead of tabs. fatih/vim-go - Jump to definition, format, auto-import, build and jump to error lines inside vim, etc.
Thankfully Neovim is getting better at debugging, so maybe I'll go that direction.
Modal editing never stuck with me, I just ended up writing more and more conventional shortcuts, so much so that I wrote my own "No Vim" mode plugin [1]. Just like VSCode and other editors have "Vim mode", so too does Vim have a "conventional mode".
So don't let modal editing be a factor in your considerations.
Everything is a shortcut, which makes it very easy to navigate, replace and much more. For example, replacing is very easy in vim: you can use substitution, r key, while in other IDEs you need to go to a menu or press on some button or other but not as easy in vim. For me navigation in vim changes my productivity, in terms of getting to EOF, end of line or other. This is my personal opinion, but you might feel more comfortable with a normal IDE.
Also note that learning vim can take some time and patience is a must.
With more advanced stuff like macros and substitutions, tedious reorganisation/refactoring becomes much faster.
And you can slap on IDE-like features with language servers and the like. It isn't as powerful as an IDE, but it will also be much less complex. Or use a Vim plugin for your IDE and accept the tradeoff: losing Vim features for more IDE features.
It takes a while to learn the editing model and hence get a return on your investment, so keep that in mind.
There are some die-hards who refuse to take their fingers off the home row to do anything, but in reality the milliseconds you might shave off here and there by using hjkl instead of arrow keys, or elaborate vim commands instead of OS-native keyboard navigation, they're never going to add up to the hours you spend peering at code trying to figure out what it does, or waiting for a compile, or running unit tests, or a million other things developers do every day.
That said, I still use (and maintain) a vim extension for VSCode. I use vi/vim style navigation almost every day at work, on and off, alongside OS-native keyboard navigation and IDE-specific shortcuts. The value of knowing vi is that any time you are logged into a remote server you can just run it and know it will behave the way it always did.
My personal recommendation is learn vi "to an acceptable degree" and then stop. vi is the thing that is available everywhere. Busybox-based distros like Alpine and the BSDs don't have vim out of the box, and some container-based versions of established distros like Fedora have a very cut-down version called vim-minimal, so if you start to depend on more advanced vim features, you will be annoyed or confused when you are in an emergency situation and they aren't there.
Personally I don't think it is worth the effort to learn esoteric vim commands or trick out your install, unless you are interested in it just for the sake of learning something new. A lot of vim users will tell you it's worth the effort, but they can't really be objective because of the sunk cost of having spent so much time learning it and setting it up in the first place. My .vimrc is about 20 lines, the first of which is an exact copy of the .exrc I've been using since 1998. When vim is available, it gives me a slightly nicer experience than vanilla vi. When it isn't available, I can still do everything I need to do. And when I'm in VSCode and the muscle memory tells me to df- or JJJ, well that works too.
Main problem I had was different keybinding on android, web browsers etc... Using Vim everywhere would be great, but I had to constantly shift between two very different styles. Very frustrating.
Another problem is that Vim sucks as IDE. You constantly have to babysit and debug plugins. Any advanced features will bring plugin conflicts... Compared to Idea it is a nightmare.
For terminal editing I use Micro editor.
1. vi is ubiquitous. So if you're even in a situation where you SSH into another machine, knowing how to use the basics of vi is valuable.
2. vim's modal editing is very expressively powerful. That's why vi-emulation (or now embedding) plugins are so popular. -- Yes, it's worth learning enough of vim's motions here. (My favourite example is e.g. `printf("hello| world");`, you can type 'change text inside `"`' using the sequence `ci"`).
Some people do have very difficult relationship with their bodies.
There's nothing inherently virtuous about using vim keybindings to edit vs standard OS keybindings. It won't make you a better programmer.
The real value is it lets you live in the terminal (and become more proficient at the command line as an extension). If you're living in a Java world, most things are done with GUIs and IDEs.
I always find it funny that people say if you add X, Y and Z to vim it becomes super useful. I translate that to mean.. if you add X, Y and Z it becomes about what you get out of the box when you get almost any IDE.
Then yes. Learn Vim because you're interested and because it makes text editing fun. If you don't enjoy it, stop. In the worst case, you've still learned the basics of a useful skill.
For actual, non-semantic text editing, the speed of vim muscle memory can’t be beat.
Personally I've enjoyed using Emacs more. With a good setup I have been more productive with that tools than I would have been with Vim.
40 year vi and Emacs user btw. I miss classic vi. Nvi isn't quite there and small aspects of Vim grind my gears.
Using it as a daily driver is a waste of time when there are much more pleasant editors to do your work in, these days.
For using via SSH it is just so convenient that it does not use any control characters for basic stuff.
i and ESC :w should also be in every programmers repertoire.
/ for search 123G for line number x d gg and G are valuable if you use vim a bit
The rest has diminishing returns unless you ssh a lot into machines without GUI.
It's a learning curve though. I'm 16 years along the curve and still learning things.
1. Vim has almost certainly staved off RSI for me. I've probably got > 10k hours physically programming under my belt. From time to time I've felt small pangs, but my worst RSI has been when I was using a mouse. Vim will also let you remap whatever you want, so you can adapt it to whatever your changing physicality is.
(Side note: I know a lot of people talk about their muscle memory, but even I as a person who can't always tell you how to do what they do in Vim have adapted here and there; most recently: Neovim changes what 'Y' does, which is ABOMINABLE DO YOU HEAR ME NEOVIM DEVS I CURSE YOU--but I adapted in like a week)
2. You can adapt Vim to help you think, and get out of you way when you're on a roll. This is more important than you might think. Vim will help you avoid blunders by letting you use whatever combination of linters and checkers you want. Vim will also let you edit code so fluently that it's close to the speed of thought.
3. Vim is open source. Not everyone is as Marxist as I am, so I recognize that this might not resonate with everyone. But as SWEs, SREs, etc., our major community is the open source community. This is our garden, our house. We should be building, using, and improving our own tools. A world in which all our tools are corporate built and owned, and used solely for the purpose of doing their bidding sounds pretty bleak. It sounds like every house is a McMansion leased from Zillow and decorated from AirBnB-approved home furnishing warehouses delivered by Uber Eats. I know that's pretty far down the road from just using VS Code, but when you think about the corporate strategy behind it, what else could it be?
That's because you're doing it wrong! Hjkl are fallbacks to move a few characters, it has only a minor advantage over arrow keys are is probably not worth the effort of re-learning how to move a cursor.
I would not recommend learning that as your first vim move. Just stick to cursors for moving individual characters at first.
The real magic is in going back/forward words (b/w/e) without needing to reach for control at the edge of your keyboard, jumping to an exact point you need (f/F/t/T) if it has a unique character (like the ')' within 'if (uid == 0)'), moving between paragraphs ({/}), going to matching parens/braces/brackets (%), going to the next/previous word under the cursor (*/#), etc. This is what will make you faster, not the switching from arrows to hjkl.
And that's just cursor moving. For editing, things like S to replace the line or C to replace the rest of the line after the cursor, di) to cut the part within parentheses and p (paste) it elsewhere, repeating the previous action with dot, searching with n/N instead of a function key, all those things are what makes vim nicer as a text editor. One of the least-appreciated things that I also use a lot is filename completion with ctrl+xf (sysadmins, take note!).
But I don't recommend learning everything at once. If you know how to go into insert mode (i), how to leave insert mode (escape), and how to save a file, then you basically have the equivalent of a text editor, especially with mouse mode enabled (the default nowadays, I think). From there, learn one command every week. Takes 1 minute per week and you'll know more vim than 99% of developers within a year.
Or go a bit faster and try to learn one command every morning, or every second day perhaps. Try it for one month and see if you want to go back to standard editors. Odds are, you'll want the best of both worlds, start looking for vim key binding plugins in IDEs, and end up like me with missing vim after all because those keybind plugins are usually not so great ^^'
> mostly using Java IDEs, and lately some vscode (for go, typescript, rust)
Do you need intelligent autocompletion, debugging, and other such IDE features?
There are plugins that, so far as I know, can do a lot of what an IDE can do, but I have never bothered to set them up myself. It all seems hacky and niche, but others can tell you more if this is the type of things you're looking for. I am not a real developer myself but I write a lot of scripts (things small enough to keep a full understanding in my head) as well as documents (reports for pentests) in vim, and for that it is perfect.
OP mentions they're open to comments about Helix... but you do you yall. The comment isn't hyperbole, I used vim for 15 years, but again, whatever.