by maligree · 9y ago · 0 comments
- learn the bare minimum: up, down, left, right, deleting words and lines, stuff you do everyday
- DON'T just look for tutorials learn stuff out in the void, you'll waste time since you'll end up forgetting 95% of it. don't distract yourself. Screw four week plans, the basics you can get in an hour.
- work. write code/stuff. whenever you catch yourself pressing a button > 3 times (you know, left-left-left-left or something like that) THEN look for a better solution. you'll discover plenty ways to navigate around the code you're working with. find a new way, stop looking, start using it.
- happy? no pain points? good. keep using vim, wait until you find something you'd like to improve. look for a solution.
The point is... just because vim can do something, doesn't mean you need to know it. It doesn't mean you need to use it. It's a tool, it's optional.
The other point I guess is... stop worrying so much about if you're using something "right". Are you happy with your workflow? Good! That's what we're aiming for.
These plans and intros and guides... it's almost like they're meant to overwhelm. It's a damn text editor, you can use 4 commands and be happy. There are no rewards and no raises for "knowing" 60%+ of vim's feature set. And after the basic what, 20%? it's diminishing returns anyway.
If anyone's interested in learning vim, I'd suggest just using it anywhere you'd otherwise use nano. You don't have to jump in head-first and use it like an IDE for coding or anything.
I've switched to neovim as my main editor months ago. I like it, but I still use the arrows to navigate, or sometimes the `w` to jump words and `10j` to go 10 lines down for example.
But I go in and out of insert mode all the time, and hjkl is not useful at all there. So I never use hjkl to navigate. Never. So how come most people use those as the main navigation?
Am I missing something?
jk are usefull for navigating lines, especially with 'dd' 'yy' and 'p'. hl are for navigating either within a word, or when dealing with a syntactic mess where the standard movements aren't very useful. Outside that, bwe and their capital variants are great. In text, so are ( and ).
Beyond that, I'd look into text objects. Things like ciw ca) or ci] are great for just doing what you want to do. (Change the word below the cursor, change an entire () expression, or change the inside of a [ expression).
There's one that's already built in: ctrl-[.
These days I've mapped CAPSLOCk to ESC and super happy with it.
And for those who use caps-lock, how do you deal with getting uppercase letters depending on how many times you pressed caps-lock? Sounds impractical to me. Every "Esc" you hit will change to uppercase/lowercase. Right?
Also, most beginners use insert mode too much. If you find yourself going into insert mode just to change a letter or word, try learning shortcuts instead (r for replace, ciw for replace word, diw for delete word, and other neat command combinations).
Maybe I'm too lazy to memorize them, I don't know.
But using hjkl is still too weird for me, even after using vim for more than 6 months. :)
It's very natural to use j and k. When you touch type, "j" is your right index home base (I assume you know it but that's why there's a physical marker on "j" and "f").
x cuts the character under the cursor and p pastes it after the cursor. Net effect is exchanging the character on the cursor with the one to the right of the cursor.
ddp
dd deletes a line and p pastes the deleted line below the current line. Since your cursor ends up in the line after the line you just deleted, this ends up effectively exchanging the lines.it is a little painful when you have to do many minor text changes in quick succession.
and ultimately, this is what made me just go straight to emacs and i have not looked back since.
emacs may take some use to getting started, esp if you are on osx (rebind command as meta) but it gives you the best of both worlds. the choices are unlimited and you get to program your own editor you want it to be.
I assume one can set up something similar for real vim.
I remember feeling combinations of motions with edit commands were like the superpowers when I first saw them. I had to look them up again several times whenever I needed them to get it right. But once I got it, suddenly predicting them to edit text on vim transcended into fun territory for me personally.
Though for vim, I have found to adopt only one or two new things a week at max to improve productivity. Anything more and it used to get overwhelming, or i forgot about it anyways...