Ask HN: How to become good at Emacs/Vim?
I've tried switching from IDEs like VSCode to Emacs (with evil mode) a few times now, but I always gave up after a while because my productivity decreases. Even after 1-2 weeks it's still not close to what it was with VScode. That's frustrating. But when I watch proficient people using these editors I'm always amazed at what they can do, and they appear more productive than I am with VSCode. So with enough effort it should be a worthwhile investment.
I think my problem is the lack of a structured guide/tutorial focused on real-world project usage. I can do all basic operations, but I'm probably doing them in an inefficient way, which ends up being slower than a GUI. But I don't know what I don't know, so I don't know what commands and keybindings I should use instead or what my options are.
How did you become good at using these editors? Just using them doesn't really work because by myself I'd never discover most of the features and keybindings.
83 comments
[ 3.8 ms ] story [ 147 ms ] threadAfter I got the basic movements down (doing vimtutor if I needed refresher), then I would watch videos on youtube of peoples favourite keybinds, or lesser known keybinds. A lot of times this would open up a lot of things I didn't realize was possible.
Eventually I started to understand the vim "language", and things became natural to the point where I don't even really think about the keybinds I'm using, it just happens.
It was definitely a struggle at first though. If I could go back and be a TA again for intro to programming labs I would have found a way to give people extra credit for learning vim. The best time to start putting in the work is now, you'll thank yourself later.
If you program in C, google "Ctags" and the associated keybinds and vim command line argument (-t). Most useful utility for me personally.
I used vimtutor on Mac to get started.
Then I also tried my hands at a few vimgolfs and then tried to understand the winning answers.
There’s a lot of YouTube tutorials now too.
It gets a bit weirder from there. If you pick vim for example theres a whole lot of customization rabbit holes you can go down. My advice is to find some sensible defaults and layer in stuff as you need it from there. vim-sensible[0] is a good start.
Good luck!
[0] - https://github.com/tpope/vim-sensible
It finally clicked when I started a job where I had to use a windows laptop with a linux VM as my primary computer. I found that using vscode either within the VM or over "Remote-SSH" from windows was severely cramping my productivity. So I switched to NeoVim+Tmux cold turkey (SSHing into VM using "Windows Terminal"). I set up some shortcuts that made sense for me somewhat from vscode (e.g. Alt+<number> for switching "tabs", alt+hjkl or alt+arrow keys to switch between tmux panes etc.). Within a couple of weeks I was back to my old level of productivity.
My usual setup has neovim on the left and a terminal in the right pane. Adding more panes vertically or horizontally is super easy as well. This may not be the most optimal setup, and there are still a few pain points from time to time - particularly with the LSP/"intellisense" stuff. But it works for me.
Oh and when I am coding on my MacBook Pro at home, I still prefer to use vscode + iTerm.
Some resources that helped:
"Practical Vim" by Drew Neil. I didn't read it cover to cover but I have scanned through it enough to pick up the important stuff.
https://www.youtube.com/watch?v=iF4RvQq6yU0
https://www.youtube.com/watch?v=GUptUQGrJLE
https://www.youtube.com/watch?v=wlR5gYd6um0
Also, check out fugitive by tim pope. It’s a git plugin for vim that’s changed my life. It’ll open your files with the old version in one split and the new version in another. You can then pull in changes chunk by chunk. It’s amazing.
Taking those and making a point to work them into muscle memory has been key.
Eventually I found that I was familiar with the core modifiers (and figuring out new things) without any real effort. I knew that shift + something would do a specific thing
It takes knowing about the thing... and using it so much that you don't even have to think about it
The cases where I'm a little bit beyond what one can reasonably handle with sed is when I get to flex the vim muscles. Things like visual mode, finding/replacing, etc.
It helped me to be a better vimmer, and it was fun too!
I'm terrible at it.
But, this is great!
Get the basic operations down, keep a cheatsheet handy, anything you'd want to do that you think might have a key combo look it up the minute you need it. Take an interest in it for it's own sake every now and then.
I've been using Emacs for five years. When I got started, I also started journaling daily with Org-mode. That gave me a reason to open Emacs every day.
My view is that it’s just like learning a language (albeit easier) and you just need to give yourself space and time. Structure is good, but can also be overwhelming in the sense that you try to min max like vim pros from youtube. I just found that I would take it in digestible pieces and build on that. First it was jumping lines, then changing inside or around, and so on and so on.
1. Modal editing (VIM / Evil): Install vim extension pack[1][2][3] for VSCode. This should give a good starter pack.
2. Practice:
3. Next install emacs with a configuration repository[4]. Most of your practice in VSCode vim should apply almost directly.4. With emacs, you have a vast operating surface. You can choose to use it just as your editor or you can use it as an operating system: email, calendering, note taking, calculations, twitter, rss, text based browser, file manager, http request playground etc. Org mode is essential emacs experience. You can add the rest of them very slowly
[1]: vscodevim.vim: https://marketplace.visualstudio.com/items?itemName=vscodevi...
[2]: vspacecode.vspacecode: https://marketplace.visualstudio.com/items?itemName=VSpaceCo...
[3]: vspacecode.whichkey: https://marketplace.visualstudio.com/items?itemName=VSpaceCo...
[4]: doom emacs: https://github.com/doomemacs/doomemacs
I'd say using Vim Keybindings in VSCode, being able to use Vim when on some remote machine and using Doom Emacs with its included packages is a good approach for improving without investing too much time.
[1] https://youtube.com/playlist?list=PLhXZp00uXBk4np17N39WvB80z...
Vscode also has vim keybindings available.
1. Don't. There's no need to 'switch'. There are marvellously 'productive' developers using every editor under the sun, and neither the quality nor quantity of their work is strongly related to their choice of editor. There are world-class developers who do everything in a vanilla Sublime Text. Others who have a fully tricked-out emacs who dream in org mode. Some use a mouse in one hand and do keyboard shortcuts in the other. None of it matters much. Ignore antiempirical self-attestations to the contrary - they're entertaining but informationally worthless. If self-attestations were relevant, then everything (from quack medicines to cult healing methods to levitation) would be true, because everything has more utterly self-convinced dataless self-attestations than you could absorb in all a bodhisattva's recalled lifetimes. [all scare quotes intended].
2. Do. Emacs and vim/nvim are great and will serve you well if one matches your preferences. Pick one using your preferred criteria, and commit to it for a period. Your 1-2 weeks just isn't enough - I'd say 2 months at least. Put that commitment in your calendar. If it slows you down too much for practicality to start with, limit its use (to an an hour a day, or to a side project), but stick with it for the full period regardless. In the first week or two, go through enough basic tutorials to be able to do essential editing with their basic keybindings without plugins. With reasonable fluency established, just keep a note in which to jot down what's missing compared to your IDE, and pick them off, one-by-one, over time. Sort the list once a week to keep it fresh, and just pick the next item to configure/learn. Get fluent with each new item before moving on to the next.
My co fig now is really simple: I rely on other's work: I find powerline-10k + LunarVim to make for a more than good enough terminal environment.
This is just as much a caricature as the one you're objecting to. People do good work using all of the available tools. Some use more than one! There are people who like both emacs and IntelliJ! We really don't have to tribalize over every little choice people make.
Like, if you want to tell me "I use nothing but notepad, and I'm a god at it" I'm going to be "holy hell yeah, I want to feast my eyes upon this marvel"... but, first off, I'm betting at that point you are going to have gotten really good at using notepad, along with all of the little warts of how it interacts with Explorer... and second off, the people who are coming out always to bash on the people who bother to learn and optimize their tools to prepare for a lifetime of software development generally aren't people who simply chose a different tool.
You're laying out a false dichotomy.
(And yes, IDE-of-the-week is definitely a thing. The shear number of different one-off text editors and IDEs for various language stacks I've seen people try to get me to use over the past 25 years is staggering.)
I did once use emacs extensively. I stopped because at the time I moved almost exclusively into iOS work, which mostly meant XCode. I disliked that enough that I tried and enjoyed the only real alternative - Jetbrains' AppCode. So then when I moved on again to non-iOS work I had fallen for the Jetbrains approach, so mostly used IntelliJ. I did have one small spell again with emacs, when writing some clojure (for which it's a good fit), but found it overwrought for my more recent taste.
But all this time I had used vim for small on-off and in-terminal edits, and mostly used vim keybinds in other editors. Anyway, via a couple more shifts (including using VSCode for a while), the advent of LSP and treesitter really makes neovim close enough to matching IntelliJ's features for my purposes. I just like neovim and its ecosystem, and it works well enough for me. But so would emacs or IntelliJ or VSCode or vim or emacs. I probably make several choices a week far more significant than what text editor to use.
I tried VS Code as well but did not enjoy the experience. Back to Emacs with which I have too many habits and a long love affair. I also use Atom a bit for some tasks but it's more rare.
You also don't need to configure your IDE from the start. It's a bit of a thankless task but not that difficult or incomprehensible. It took me a few years before I started messing with my Emacs configuration. The advantage is that it is portable and I can find my environment on any computer just by copying a folder.
I used Vim (GVim to be specific) as part of my job in a semiconductor industry. Everybody in our team used it and we'd help each other. My recollection is not 100% sure, but I think nobody knew how awesome user manuals were (start with vimtutor and then go through `:h usr_toc.txt` https://vimhelp.org/usr_toc.txt.html a few times).
I've also collected a list of Vim resources here: https://learnbyexample.github.io/curated_resources/vim.html
For Emacs, check out https://www.emacswiki.org/emacs/SiteMap
- [x] SpaceVim, SpaceMacs
- [ ] awesome-vim > Learning Vim https://github.com/akrawchyk/awesome-vim#learning-vim
- [x] https://learnxinyminutes.com/docs/vim/
- [ ]
- [ ] https://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim/Mod... : - [ ] my dotvim with regexable comments: https://github.com/westurner/dotvim/blob/master/vimrcAt least 75% of Vim users I’ve encountered don’t know Vim well enough to justify their using it. Most users stop at vimtutor and are left without the knowledge of the terrible nightmare of Vim knowledge you need to get close to useful editing.
Also keep in mind Vim is a text editor, not a code editor. IDEs are incredibly more powerful than Vim for code editing.
What's the 90% that's not available in VSCode with the Vim extension?
Emacs is a lifelong journey. Expecting to be great at it in a few weeks is very unrealistic.
To answer your question I spent a week reading a book on Emacs and forced myself to figure out any task rather than reaching for another editor. This was for the editing part.
For the IDE, my default is to use another IDE and as time permits I try to replicate features in Emacs - but I never have an obsession to completely replace an IDE.
Watching the system crafters YouTube channel will teach you about a lot of cool features and packages. Highly recommend it.
Monitoring the Emacs subreddit is a good source of inspiration as well.
Ultimately people use Emacs because they enjoy it - not because it is a superior IDE. If you're frustrated with Emacs, consider that it's not for you.
Then after that, I just started using vim and keeping with it. To me, the biggest hurdle was switching between modes. Hitting esc was too far for me. So I found some post that helped me configure vim that bound "ii" to command mode. So to switch between insert mode and command mode was just "i" and "ii".
Nowadays, I use the escape key. It's second nature by now. But I'm still trying to make navigation with 't' and 'f' more natural. I think it's just persisting, honestly.
No, seriously, why do you think you have to switch if you are productive with VSCode?
I used to be all in with Vim and then Emacs many years ago. I can manage pretty well with both to this day. But I moved onto VSCode a few years ago and… it’s very nice. It just works out of the box. I have tried to move back to Emacs for example, but the lack of trivial and good remoting features and the lack of great LSP integration are hard to overcome.
Nowadays I still use vim for quick or repetitive edits (learn how to record and replay macros; they are a game changer), but otherwise spend all of my time in VSCode with its Vim mode enabled.
And to be fair, I only use the Vim mode in VSCode because I moved from macOS to Windows and I could not stand the Windows native shortcuts.
isnt emacs just M-x ssh … and ure done?