7 ms·
Alternatively, don't try to hurry enlightenment. First, learn :q! Next h,j,k,l Then i and ESC Finally :w Now you know vim. Don't let p
by sevensor 9y ago
Alternatively, don't try to hurry enlightenment.
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.
- caiob 9y ago> Mode confusion is a feature, not a bug. Then you realize that insert mode is the least useful mode there is.
- papaver 9y agototally agreed. the best way to learn vim is slowly. teach your self one thing a day and use it all day. if you keep using it great, if not move on to the next thing. otherwise you get brain overload and someone is trying to teach you how THEY use vim and you don't create your own style.
- Tarean 9y agoI'd argue that text objects are by far the biggest advantage vim has over other editing models. From my experience they are pretty easy to learn for programmers.
- leggomylibro 9y agoI like the "Learn Vim Progressively" guide. It starts with just a few commands, and introduces new ones in small batches when you feel comfortable with the ones you're using. http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/ 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.
- amhenk 9y agoI feel like window management is a good way to introduce vimscript as well. Lets you tweak some of the features like having the windows open on the right instead of left or getting rid of the w so it's just ctrl+{hjkl}.
- sevensor 9y agoI learned vi 20 years ago now, and vim a year or three later. In all that time, I've never seen the point to vimscript. If you want a heavily customized, scriptable editor, why just not use emacs? Vi works the way it works.
- lorenzfx 9y agoI always recommend 'Your problem with Vim is that you don't grok vi.' to new users starting out in vim [0]. You can never learn about the language of vim too early. [0] https://stackoverflow.com/a/1220118/2131903 https://stackoverflow.com/a/1220118/2131903
- sevensor 9y agoThat's a very informative link -- I can see how that might be helpful context for a new user. It's hard for me to get into that mental frame, since my first text editor was edlin for DOS. I'll stick by my recommendation to type first and study later, however. Experience is a powerful teacher.
- exist 9y agoThank you for that link. I appreciate that he chose to intersperse the history of commands (such as grep!) within his explanation.
- RunawayGalaxy 9y agoThat was enlightening. Thanks for sharing!
- peacelilly 9y ago`vimtutor` is where most people should start. It's bundled with every vim installation. Vimtutor teaches the absolute basics in an interactive manner so you'll remember the lessons.
- edanm 9y agoSorry, but I think that's really bad advice. 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.
- sevensor 9y agoI think we just don't agree about what the good parts of vim are. I find f and t to be a minute improvement over forward search. I think hjkl is strictly better than arrow keys, because you don't have to move your fingers from the home row to navigate a file, and I think the basic editing commands I outlined are sufficient for a superior editing experience within a day of learning them, no deep study required.
- autokad 9y agoi'm sure it becomes intuitive with lots of use, bit i find it awkward with having to move my finger off the home keys to move left. somehow for me, its even more confusing that way. where as my arrow keys are completely intuitive, one finger for the left and right keys and the middle finger handles up down. to me its not a big deal to remove my fingers from the home row if i already have to move from the home keys.
- deleted 9y ago[deleted]
- aidos 9y ago
- quickthrower2 9y agoIf you are relying on accidentally f'ing things up then u and ctrl-r are essential too. u is my favourite!
- AndrewOMartin 9y agoI came to the comments after a bit of the tutorial to write something along the same lines but less eloquently. I absolutely agree, too much too fast. 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.
- spike021 9y ago>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 Same with using 's'. Super handy when you accidentally type the wrong character.
- rifung 9y ago> i and ESC I think i and Ctrl+[ is better? It's more in line with the idea of keeping your hands near home row.
- sevensor 9y agoIt's a fair point. I learned ESC long years before ^[ and it's stuck in my muscle memory. But a new user might benefit from using ^[ instead. Some keyboards put F1 where ESC belongs, and my habit has been to remap F1 to NOP because help is so annoying, but maybe I should remap ESC to help. That would get me to switch over in short order.
- SAI_Peregrinus 9y agoI've remapped capslock to ESC. I can't remember ever wanting to use capslock mode since I first learned to touch type. Much easier to have Esc there. Or Backspace, Home, End, or delete are also good options.
- Analog24 9y agoI mapped capslock to Control and use Control-c instead of escape. It's much easier on my pinky.
- dkersten 9y agoLike sibling, I also mapped capslock to control. I use ^[ instead of ESC and there are other control-<whatever> shortcuts that are extremely useful, so it gets more utility than ESC would. Of course, then I bought a kinesis advantage2 keyboard and now suddenly every key is easy to press, even the cursor keys.
- fiddlerwoaroof 9y agoI work at a company where we pair on everything. The feature that generally converts people is keyboard macros, after I use them to automatically perform some tedious code transformation.
- hzhou321 9y agoI missed my chance of learning vim properly and I never internalized h I j k. After trying a few episodes of forcing myself to use h I j k miserably, I question that wisdom. The fact is I never find arrow keys a hindrance, probably when I navigate with arrow keys, I am always unclear of my editing goals and I can use some slowdown thinking anyway
- mrmondo 9y agoAs a heavy vim user for 15~ years I don't find h,j,k,l useful and for new users that may be one of the most confusing / alien changes.
- boomlinde 9y agoI still find them useful, but they're just another navigation tool as opposed to the main navigational commands a newcomer might use them as. There are frequently situations where I can easily move next to the character I want to operate on and adjust the position with h or l.
- grondilu 9y agoAgreed, though arguably you need to tell newbs that in order to quit, they must type <Esc>:q!, not just :q!
- bradezone 9y ago"Mode confusion is a feature, not a bug." Just one reason why vim is the most overrated POS of all time.