This article was originally posted in barbarianmeetscoding.com. 😊
Since I became a programmer I've been quite fixated with the idea of making more...
For further actions, you may consider blocking this person and/or reporting abuse
Hi! 😊 Thank you very much for leaving a comment! :D
My intent wasn't to be religious in any way but to share something I find useful, interesting and which I think has helped me become a more productive programmer.
I used this quote:
Because it perfectly describes the feeling/intent that I had when I started learning vim. I love to continuously examine how I am doing things, see where I feel pain and try to improve. So you could say that I'm always for raising my game. At the time when I learned vim, I was super proficient with Visual Studio and ReSharper but I felt that my flow was often stopped or slowed down when doing small refactorings (like at the code block or code line level). It that context, vs(vim) was a great combination with ReSharper. And, even if it didn't improve my productivity measurably (I never went back or exhaustively quantified the difference between before and after adopting vim), it did make me feel like a coding wizard as I became a lot more fluent when coding (which I think is a good thing :D).
I certainly didn't mean it as exclusionary or demeaning of anyone using other editors.
Totally agreed
No :) I can give you a lot of examples where keyboard is superior to mouse movement + click combination. The click is not the slow part of using a mouse. The slow part is lifting your hand from the keyboard, grabbing the mouse, moving the mouse where it needs to be, clicking and then moving your hand back to the keyboard. This is not only slower, it also breaks your flow.
cw{insert}<ESC>
gt
C-p {start typing filename} <ENTER>
:e {filename}
Note that keyboard superiority is not limited to vim. Any editor provides shortcuts because they're just faster than using the mouse. Learn your editor shortcuts and you're going to be infinitely more proficient than you were when you used the mouse.
I think that we just don't see things alike and we don't need to discuss it further. :D
This was awesome. Thanks for posting.
Now I need to plug Atom's vim-mode-plus, specifically, it's incredible occurrence operators:
d o i l
delete occurrence in line - deletes all instances of the current word in linec o i l
change occurrence in line - changes all instances of the current word in linec o i p
change occurrence in paragraph - changes all instances of the current word in the paragraph - perfect for refactoring the name of a function paramc o i p
change occurrence in paragraph - changes all instances of the current word in the paragraph - perfect for refactoring the name of a function paramAnd even more. I'm so completely hooked on these workflows because they're so nice.
I also added some vim/emmet crossover keymappings, like
That one's clutch:
With cursor at
⌨️
, I escape to normal mode and hitg e r t
and voila - I getI'm so hooked on VIM, I even baked simple commands into my keyboard's firmware. It's a little buggy, but you're free to use it, and if you're interested, PR's are welcome ;)
Thank you! And thank you for the comment!
I really like the occurrence operator. It feels very convenient! Like a shortcut for the vim substitute command that plugs in as a text object with all other commands. I'm not fluent enough in vimscript yet but it sounds like something that could be implemented as a vim plugin :D
Stop it. You had me at "Vim"
I remember a post where someone compared their
.vimrc
to a zen garden or something like that. They said that they loved visiting that file and make a few tweaks every now and then.That post was right, it is surprisingly entertaining to find out that Vim has a motion/command/whatever that is useful (like go to matching curly brace) and go to your config file and make it even more convenient. Piece by piece it grows into something that makes you productive and you love it because it's yours and you made it.
hahaha :D
It does indeed feel like a beautiful zen garden _^
It's all cool and geekish but in real world any other modern editor is just more practical and productive. There is absolutely no point to learn billion of shortcuts for basic stuff. Writing code is not about typing, that part of coding takes like 20% of work and most of it doesn't require vim-like spell casting on the text.
It is more than enough to have editor like Atom or VS Code which you can extend with plugins at your need. There are plenty stuff to learn in modern programming, why would you add on top of that learning a whole vocabulary of unnecessary shortcuts which won't even benefit you much.
Thank you for your comment!
A modern editor is definitely more practical because they typically have a great user experience from the get-go and you don't need to configure anything to get started. In my experience using a modern editor in combination with vim (a vim plugin) is amazing. You don't need to learn a billion shortcuts right away, you go learning them one by one as you go, normally when you feel the pain and wonder "there's got to be a better way to do this".
Even if 20% of our work is writing code (we don't need to debate that), I prefer that 20% to be frictionless, and vim allows me to be extremely adept at writing and changing code, so that I can express whatever is in my head in code in a fast and smooth way. If we all have a finite amount of keystrokes in our lifetimes, vim allows me to make them count :D. Then there's also the pride and joy of being very good at what you do.
Whether vim itself is better than a modern editor that's something that I haven't figured out yet. For me there's a couple of things I haven't been able to make work properly with vim yet: One thing is aesthetics and the other is statement completion to the level of TypeScript in VSCode.
There's a deeper thread in this article which transcends Vim. The thread is to master your tools and become proficient at whichever editor you use. Vim somewhat guides/forces you in that direction, because of its keyboard centered nature, its necessary configurability and its culture of extensibility.
It’s not about learning shortcuts, it’s about productivity and focus. But you can only understand this once you start using it.
Yep :) There's things you just need to try yourself before you can understand them.
They can tell you all the things about how it feels to have a child. But you won't truly get it until you have one yourself.
hehe you are right. Using counts is not very efficient. It's ok for 2-3 items but beyond that is more time consuming (it's just hard to count words/characters by just looking at them).
For that particular use case, you can use pattern searches:
?{pattern}<Enter>
and you're there. That in combination withn
/N
to repeat last search forward or backward and it's pretty much instant.?{pattern}
to search upward and/{pattern}
to search downward"This is a very bad first impression and I've twice given up on learning vim just because of this. (Let's learn vim! Open vim! Ain't got time for this...)" That's me yesterday after I installed it 😅 thanks for the post, I'm gonna give it a try again today 🙏
hehe I know right :D Let me know how it goes :)
Love your article and I love how popular it appears to be! I have been a Come user for a couple years now and am so thankful kful I learned it. One neat little tricky I found in Gmail, if you have the keyboard shortcuts turned on, they simulate vim movements 😀
Thank you!
Yes! If you take a look at the shortcuts of a lot of popular services you'll see that they use common vim key bindings. One is gmail, another one is twitter, trello if I don't remember wrong and many more.
Awesome! Honestly I like to think that this is a programmers subtle way of vim evangelising 😁
Your post is just awesome!
As a daily vim user, I always feel frustrated when reading such articles because I'm not using 1% of these features.
However, the only 10 commands I've been using for 18 years are enough for my needs. Your post is the best explanation of why I'll never learn more. It's too complicated.
That's the great thing with Vim: even using 1% of the features already makes you 100% more productive!
Hi Boris! Thank you and thank you for leaving a comment! :D
Don't feel bad for not using all the features. It is more practical to learn and use a little at a time in a way that makes sense with your workflow and needs. If you one day start doing something and start feeling pain, then that's the perfect motivator to find out whether there's a better way of doing that something. I've been using vim for ~5 years and I think there's more stuff I've learned over the past two months that I ever knew existed those past 5 years :D.
Great article. Lots of new commands I will try. I started with vim in an internship 6 months ago. Actually I started with a vim plugin in Visual Studio. At first it was hard, I wasn't a typist (typed with 3 fingers on each hand for the last 15 years) and I was not very productive.
Then a friend of mine really convinced me. At the same time, I learned how vim works and how to type with all y fingers. It was a very painful moment but I am happy I learned all that. It significantly boosted my productivity.
Basically, I learned by searching for what I wanted to do then write it on a sheet. I made my own cheat sheet and it really helped me learn a lot of Vim syntax.
Now my laptop for college is fully running Linux, I use clion as my principal IDE and I use ideaVim plugin. For me, a vim plugin in a IDE is the best of both worlds. I have all the advantages of my IDE with an extra layer of power.
I've setup my default text editor in my shell and on git to be vim and I am actually quite decent using the real thing.
Hi Jim! Thank you for your comment! _^
I also started using VsVim with Visual Studio and also wasn't a typist. The first week was excruciatingly slow :D. Just switching to touch typing (without vim) took me at least a month of early mornings and late afternoons just practicing touch typing. I even overstrained my wrists and the pain lasted for months. But in the end it all worked out just like in your case :D
Great idea! :D
f'ci'MAN<ESC>
You don't need to
f'
by the way, vim will seek out the first''
pair travelling down the line. Soci'MAN
is enough ✌️Wooooooooot!!!! This is EPIC! I. Did. Not. Know. This. And if I knew it at some point in my life I had completely forgotten about it! Thank you for leaving a comment! :D 🙌
I've updated the article to add a note on that :D Thank you! It looks like this behavior only applies to the quotes text object and not the others though.
Yup, I'm not really bothered by it because the awesome targets plugin extends that behavior to the rest of the text pairs as well as arbitrary separators:
, . ; : + - = ~ _ * # / | \ & $
. That's such a sane default, I wish it was in vim to begin with!Oooooh that's so gooooood! Indeed that feels like it should be the default behavior. I had started a thread in my brain thinking about how I could implement that behavior for the rest of the operators but it is awesome there's already a plugin that does that! Thank you for sharing!!!! :D
Vim is a very powerful tool--that's for sure. But still, after reading this post I'll still only use VIM for quick edit on scripts. Not a full time editor for programming. I don't think it will raise my game either.
Thanks for sharing this wonderful article!
Thank you Gene! :D
There are another brilliant series for Vim beginners from Derek Wyatt.
Basically, if you manage to break through the first hard time learning Vim, I doubt you will ever drop it.
Cool! Thanks for sharing! :D
There are other great resources for vim:
vimtutor - a basic tutorial that ships with vim. This gets you comfortable with the basics of moving around and changing text.
Your problem with vim is that you don't grok vi
Learn vimscript the hard way
After that the book already mentioned: Practical Vim
Than you for the comment! I do mention
vimtutor
in the article and thank you for sharing the other resources. You don't grok vi is really good and I'm looking forward to reading learn vimscript the hard way (it's on my kindle :D). I already have a plugin in mind I'd love to write.I've made a few casual threats to learn Vim before. The ubiquity argument is a good one, but it wasn't enough to get me to put in the effort. And then I needed a replacement editor at the office. I'm an Emacs user, I like Emacs, I'd prefer Emacs, but I can't use it at work for reasons that are dumb. Vim seems like a viable option I think. If it doesn't work out then I guess I'll have to give VS Code a try. Although that's going to leave me with many of the same problems I have now.
Try it out, have some patience and you may fall in love :D
People often pitch this as a reason to use neovim. Vim also comes with an integrated terminal (well, it depends which options your version was built with) and has for a while. When neovim evangelists say it has a terminal it's a bit like BMW fans saying that their car is better than your Ford because it comes with seats.
As far as sensible defaults go, that's a whole can of worms. An awful lot of people disagree with anyone else's idea of "sensible"...
Hi Ben! Than you for the comment!
I have to admit I don't have a strong opinion here but I do think that neovim defaults are sensible and provide a nicer first-time user experience to the alternative. Particularly:
Also, their effort to allow other programming communities to write plugins using languages such as lua, python, ruby and JavaScript/TypeScript is also very interesting and cool.
In regards to the terminal, I'm using nvim/vim with tmux so I haven't found a strong use case yet for the integrated terminal (just haven't had the time to dive in there yet )
Yeah, I used the built-in terminal out of curiosity a couple of times but stopped pretty quickly - I don't really see the point apart from for yanking lines out and I'm more likely to use
r!
to get shell content in anyway.NeoVim does come with a sensible scripting language though :)
Great article Jaime. After making it past the learning curve, VIM is by FAR the most efficient and effective way to do development!
Thank you!! Indeed, it is hard to find something equal to vim :D
Although I don't see myself learning Vim anytime soon, this is without a doubt one of the best articles I've read about it. I especially like the playful tone you had when explaining the keystrokes. I'm keeping this article for future references. Thanks for this!
Thank you!!! :D
Thank you!
I think I learned more from this article in 20 years of using vim (mostly because it wasn’t emacs).
What a great and detailed post. I used to get so frustrated with terminal would auto open vim. :)
Thank you!! Yes, who hasn't experienced the being-trapped-in-vim at least once? :D
I will say that if you are 'ssh' into any Linux or BSD servers knowing vim is a must. It is like a carpenter not knowing how to use a tape measure.
I use vim a little. When I write a single file I use it because it's light,
else I use vscode.
I cannot memorize those vim command.
Visual Studio Code is an awesome editor too :D
It has a vim plugin for all the shortcuts. I used vscode with the vim plugin and it was pure joy.
Indeed! It has improved a ton from the first versions _^
Thanks for this awesome post!
I watched the WAT video, laughed so hard that I needed to share it with the collegues and almost forgot to read on the rest of your post... I carried on gladly :)
Thank you Robin!!! :D OMG that video is so awesome!! I can completely understand you got sidetracked by it xDDD
Thank you for sharing it Jaime, totally made my Monday!! :)
Do you know the project vim-bootstrap vim-bootstrap.com ?
Is open source
avelino / vim-bootstrap
Vim Bootstrap is generator provides a simple method of generating a .vimrc configuration for vim
vim-bootstrap
Vim Bootstrap is generator provides a simple method of generating a .vimrc configuration for vim, NeoVim, NeoVim-Qt, MacVim and GVim.
Pre-requisites
The distribution is designed to work with Vim >= 7.4.
Mac OSX
Linux
Python bundle (optionally)
Elm bundle (optionally)
Installation
Wop! I did not! Thank you for sharing!!! This is really cool!