by sevensor · 9y ago · 0 comments
First, learn
:q!
Next h,j,k,l
Then i and ESC
Finally :w
Now you know vim. Don't let people tell you you're using too many keystrokes. Are you still reaching for the mouse? If not, you're using vim just fine.Most of the good stuff in vim, you'll learn accidentally, because you're in normal mode when you think you're in insert mode, or because you have caps lock on in normal mode and you don't realize it. Pay attention to the bizarre behavior that results and you'll learn useful tricks. Mode confusion is a feature, not a bug.
For the rest, there are certain topics that reward study and are unlikely to present themselves to you accidentally, but there's no hurry unless you're feeling the pain of not knowing them. I recommend:
1. Visual selection mode
2. Prefixing counts to commands
3. Search and replace with regular expressions
4. Advanced cursor movements
Lastly, if you're using gvim, do
:set guioptions=
at the beginning of every session. Those GUI elements will tempt you to use the mouse, when that's almost never an appropriate thing to do.Edit: learning to use x and d early on is probably also a good idea, if like me you're the kind of person who makes mistakes.
For one thing, it doesn't give new users any positive experience or reason to learn vim. If all you learn is to do things that are "pointless" (like learning hjkl), then you won't get any value out of vim. And if your way of learning is to do something that screws up your file and try to recreate how that happened, well, let's just say that every time I do something that screws up my file I'm in the middle of working, and the last thing I want is to stop and fix some random problem.
I usually recommend people try to get into vim easily, then learn the GOOD things. I.e. I think it's perfectly fine that people start with arrow keys, much as I love hjkl. But to get value out of vim, you should really learn "f" and "t", and text objects, then how they compose with "c" and "d". That is the reason I started loving vim myself - that's when I saw that it gives me something that other editors didn't give me, adn that encouraged me to explore further.
- Vim is not newbie-friendly regardless of whether you remove guioptions or not. One has to spend at least a few hours of study and practice to get comfortable with Vim. If one is forced to invest a few hours to learn an editor, one might as well get rid of guioptions and follow other advice provided in sevensor's comment.
- Learning hjkl is not really pointless. hjkl and other motion commands makes Vim a unique and ergonomically a very superior experience. If one does not want to spend time learning hjkl and other motion keys, then one might as well skip learning Vim and pickup Emacs, Sublime Text or another capable editor.
On the other hand, if I want to show someone the "good parts" of vim, I try to show them something they can't do in another editor, rather than something that they can do (arrow keys). Even if I 100% agree that arrow keys are a worse experience, it's just not as convincing as something that can't be done outside of vim.
At least in my experience.
I've recently taken this approach to emacs and org-mode. I'm a long-time vim user with a super-optimized vimrc, so I know what productivity feels like. I threw in spacemacs to reduce the learning curve, but I still was initially much less productive with org-mode and emacs than with markdown and vim for my TODO lists.
Now, after using org and emacs for three weeks, I'm at the point where several of the amazing features that I had heard about are in my bag of tricks, and it feels awesome! But I've barely tweaked my .spacemacs file, have only learned a bit of org, and am sure that I am nowhere near peak comfort/productivity/flow. But if I had tried to learn all of the things that I know are cool about org-mode, emacs, and spacemacs all at once, I wouldn't have gotten any work done over the past few weeks, and honestly I probably would have given up.
TL;DR: the fancy stuff is the best marketing, but it's best to start slow.
I just feel like it's a thing that people don't realize will help until they internalize it. Whereas almost everyone I show the text objects to immediately realizes their utility. I'm only looking at this from a pedagogical perspective.
Anyhow, I'd be really interested to know if you agree with this characterization of your outlook.
I agree. For navigation I rather use f, w, e, {,}, ctrl-l, ctrl-u, /, o. I think hjkl are overrated.
Assuming the new Vim user already knows how those work, telling them that they instead need to go `Esc -> hjkl -> i` and ending things there... that's going to leave them worse off in Vim than saying nothing.
http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressiv...
I'd add windows to your list of things to take a look at once you feel comfortable with the editor. You can split your workspace with ctrl+w followed by 'v' (vertical) or 's' (split). Then you can switch between those panes by pressing ctrl+w twice, or ctrl+w followed by hjkl or an arrow key. You can also resize the windows and stuff, it's great for things like viewing a header and source file at the same time.
I think i and Ctrl+[ is better? It's more in line with the idea of keeping your hands near home row.
Of course, then I bought a kinesis advantage2 keyboard and now suddenly every key is easy to press, even the cursor keys.
Same with using 's'. Super handy when you accidentally type the wrong character.
My hackles were raised when it starts with "ESC" to enter normal mode and "i" for insert mode. Rather than "i" for insert mode and "ESC" to get out of insert mode. Also, I used the arrow keys to move around in vim for ages before I disabled them.
u is my favourite!
Then you realize that insert mode is the least useful mode there is.