Beginner’s Command Cheatsheet
:q!
Shift + ZZ even easier
Shift + ZQ to close without saving!
At least not an operating system like a certain “text editor”.
“Why are we running from the police, Daddy?”
“Because we use Emacs, son. They use vim.”
–old Slashdot T-shirt
Emacs is a nice one as well. Its approach and purposes are just different. But in my opinion difference has a lot of benefits, so long life to all the editors and a big thank you to the wonderful devs who offer these tools to us (remember to buy them a coffee or more if you can).
Seems like one loves vim or one does not. I learned vi back in the mid 80s, hated it then, probablty not going back. These days I thankfully use Geany or nano. Learning vim seems like a right of passage or something.
Learning vim seems like a right of passage or something.
Yes, I think every developer is dropped into vim unexpectedly at some point (eg. git)… “What is this? How do I close it!!!”
Don’t code with Vim. Vim with code.
After a decade of using the bare minimum vi modes I just yesterday discovered I could use visual mode to jointly indent multiple lines.
I will still prefer pycharm every day of the week over vim, but yesterday I needed to modify code on a server and rebuild some docker containers. I couldn’t be arsed setting up my local env, making a merge request etc and was pretty impressed that a combination of screen, vim, docker compose and git - all available via SSH, was a complete toolset for getting an emergency change deployed and an app running again.
I use neovim btw
alias vim='nvim'
alias nano=nvim
I personally started with vim and I’m now using neovim for years. And I have to admit that it’s just an editor… But a perfectly optimized one.
It requires some efforts to learn the basic useful features (like horizontal and vertical motion) but I quickly saw its potential. What made me stick to it and willing to invest even more efforts is the fact that you build it to fit your needs like a glove through the interface customization, no limit and powerful keybindings remapping, and a collection of plugins for everything (without making it slow or bloated). With the right plugins, this editor can handle any regular typing or specific coding language, and makes your workflow way more efficient thanks to a great project management approach and/or speedy fuzzy finder file explorer.
I’ve barely started a series of posts dedicated to this incredible editor. Whether or not you’re using a vim or neovim, I’d recommend to stay curious because there’s other editors out there to be aware of and one may prefer them. I’ve tried quite some of themwhen moving to neovim but this one was just the one for me.
inb4 someone mentions an emacs lisp package for filing your taxes
The command chest sheet in that article is wrong. gg is first line of the document, not H
Almost had me believing, but I couldn’t understand this sentence and it’s all over
"In this case, yank is the verb and the second y is a synonym for y_. "
Huh? What the hell is y_?
I saw the video by noBoilerplate. How useful is knowing and using Vim-Shortcuts when writing a letter or an email? Does it only make sense to learn it if you write or code all day or is it useful enough for moderate tech users or office workers?
That would be Emacs.
Emacs is like an operating system bringing various tools into the same editing interface, including email. Emacs is very adaptive, you can get VIm like bindings through evil-mode.
I would Emacs, but my pinky can’t.
Oh I feel you. Typing too much too fast is terrible on the wrists.
I remapped some keys for the key combos and have no issues with those now. Regardless of editor, good posture may help. I find good posture easier with split keyboards which often include a thumb cluster.
Perhaps multi-modal editing is better and you can do that with evil-mode. I’ve created some prefix key combinations with Alt-Gr and with the super (windows) keys to create something like it whilst keeping most most common commands close to the default. Namely C-x is now s-c which is way more relaxing on Dvorak layout.
Doom Emacs includes evil-mode by default perhaps that’s your cup of tea.
I’d love to say yes, but I really don’t think it’s worth the time in that scenario. Learn keyboard layering instead; much less time consuming and probably better for normal E-Mail writing et al. Check out dreymar’s extend, which is extremely useful and can be used on any platform with any keyboard layout: https://dreymar.colemak.org/layers-extend.html
It’s very good for navigating and editing text quickly, and fantastic for situations like “I need to do the same thing 100 times” with things like macros. Coders are frequently opening a big, complex file, jumping around it a lot, changing big and small parts of it, and doing repetitive tasks. For something more like writing out thoughts for an email, editing them slightly, then being done with that text forever, there aren’t as many advantages, you’re spending most of your time in “insert” mode which is effectively “normal text editor that people are used to” mode. That said, it’s one of those things where when you do get used to it and start to enjoy it instead of being frustrated by how different it is, you start wanting it wherever you have to type anything.
I’ve switched to vim on a whim few months ago, and it still is a pretty fun and satisfying experience. I couldn’t get LazyVim to properly work on our Unity project, since the LSP can’t handle the hundreds of projects it generates, but IdeaVim in Rider works pretty much the same, as far as the movements are considered.
However, the important thing is that I said fun and satisfying, not faster and efficient. I still make mistakes, I have to look into a keybind reference sheet every time I want to do something I’m sure has to have a special keybind but I’ve forgotten which one it is, but once you do that it feels good.
Slowly but surely learning new stuff, getting the hang of some motions you use often, not having to reach for your mouse, all of that feels good. It’s still no way near the speed or efficiency of me just clicking the damn mouse, instead of fumbling around with VIM modes, undoing random actions because I missed one important key and now half of my text is gone, or just remembering that your clipboards get overridden by almost any action unless you do it differently.
So, if you want to get efficient and quicker in your programming, I highly recommend checking the keybind section of your IDE, and learning the few important keybinds it has, such as jump to next function/next parameter, search symbols, and the like. That will make you more efficient.
If, on the other hand, you want your editing to be a skill you can slowly continue mastering, eventually (after years of use) min-maxing, but always having some cool new things to learn that will feel good, them vim is pretty nice for that.
Just don’t expect it will make you faster or more efficient.
I’m in a similar boat. The difference for me is that I can definitely tell times where I’m faster. But there are still times where I fumble around. I know that eventually, I’ll be way faster using vim motions than I ever was without them.
When I first started actually trying to use it to do work, it felt pretty bad. But once I got over the hump it felt better.
I think I’m at the point where I’m at least as fast as I used to be, if not slightly faster.
Micro is good enough for me
Cool story
Reading this with Tridactyl, a browser add-on to bring Vim bindings to the Web.
Bonus : edited this TextArea in Vim itself via Ctrl-i
I started using PyCharm recently. I love being able to open and switch multiple terminals, access database, see code structure, tooltip on deprecated code and how to fix it, I also like jumping to declarations, inserting code snippets.
Could I do all of these too with vim or neovim?
Absolutely, but you need to set plugins for that and it’s not easy to get to the same state, but once you’re there it’s easy to surpass it. Vim has a very steep learning curve, this applies to everything from moving around the text to plugin specific stuff, but once you learn it it’s much better than any alternative I’ve ever come across (and I’ve been programming for 20 years, only switched to Nvim recently, although I’ve known basic vim since forever).
First let me tell you that I don’t know how to do all that you asked, some of it I’ve never needed, but I’m 100% sure it’s possible due to all of the other much more difficult stuff I have on my setup. The stuff that I do have, is much more convenient, e.g. with the cursor on a function/variable I can type
gd
(Go-to Declaration) to go to the declaration of it, orgr
(Go-to References) to go to a list of references for that function/variable, that’s much more efficient than using a mouse, especially when it takes me at most 4 key presses to go to anywhere on the visible screen using jumps. So at the worst case scenario it takes me 6 keystrokes to go to the declaration of something I have on my screen, which even at 70WPM it means a bit over a second, whereas moving your hand to your mouse, mouse to the thingand Ctrl+click probably takes longer and is worse for the wrist.But it’s the things that you can only do on vim that make it worth it, really you might gain a few seconds here and there, which do accumulate but it’s the stuff that seems like magic, e.g. have you ever had to replace
'
with"
on a string because you wanted to writecan't
?<space>srq"
that’s my shortcut for that, i.e. space to enter a “special mode” Surround Replace Quotes with " (srq"), and if I wanted to change from"
to'
it would be<space>srq'
so only the character I want to use change. Similarly I can do<leader>srb(
to replace parantesis/brace/brackets with a parenthesis, heck I can even do<space>srq)
to replace a quote with a parenthesis (notice I used open in the other and closed here? Open parenthesis means to add a space, closing one no space, same thing for brackets or braces). Another cool thing this plugin lets me do isciq
(Change Inside Quotes) to change all of the text inside the current/next quotes ordab
(Delete Around Brackets) to delete everything inside the brackets and the brackets themselves. And all of that is just ONE plugin that extends the basic around/inside keywords in vim. There are dozens of plugins that completely revolutionize the way you move around and edit stuff. It’s hard to learn, but it’s incredibly rewarding.Most certainly with plugins. There is a shit tone of them for basically anything you want. Learning all the keyboard commands on the other hand…