9 ms·
How to Learn Vim: A Four Week Plan
- wruza 9y ago>Consider installing auto-pairs.vim Personally I don’t like when editor puts something into buffer without my explicit command. Moreover, if you need autopairing, there is no need to depend on external script, just :imap ( ()<Esc>i
- devnonymous 9y ago/Rant Oh come off it! I hate this kind of elitist bull crap. Don't like editor putting something into buffer, do you? Do you have set ai in your vimrc? 3 guesses to what that does. How about set et? 'consent' you say? How is explicitly installing a plugin not expression of consent? And as for your dismissive jibe about 'just imap' - auto-pairs is a bit more nuanced than that. For example it handles pairing quotes as well. Let's see your quick dismissive solution for that which handles closing quotes as well. Why am I so angry? Well, because there are so many of these 'gurus' who go around being dismissive of other peoples preferences as tho their's is the only one true way. The comment could easily just have been, "I like to be explicit about entering my parentheses and even if I wasn't here's how I'd do it without a plugin ", instead of all that consent nonsense. /End rant
- Axnyff 9y agoAlso auto-pairs.vim doesn't seem to break the dot command, contrary to the mapping they provided.
- wruza 9y agoI have ~50 lines in .[g]vimrc for variables only, including ai, et. From the autopairing readme it is clear that it can do sophisticated things that :imap cannot. Edit: I like to be explicit about entering non-whitespace, but have few imaps for snippets and formatting in per-directory x.vim files, to be clear.
- wruza 9y agoBtw, I tried to use autopairing yesterday in sublime text 3. What I noticed that it is easy to get used to autopairing on entering lines, but when line is edited again, it often leads to unbalanced parethesis. Happened to me every time unless attention was paid, because it works not a like what your finger-memory expects from new line entering. Do you experience this? Does autopairing.vim solve this issue?
- majewsky 9y ago> without my explicit command Technically, the "explicit command" requirement is fulfilled because you explicitly installed the plugin.
- mettamage 9y agoHmm, I might just take this approach at face value and do exactly as he said. I only did vimtutor a couple of times and nothing else. It only gets you so far. I really appreciate the survivability that vimtutor gives me though, I feel comfortable editing text in a terminal nowadays :)
- isatty 9y agoI believe that what helped me the most (I've been using vim for 4+ years now, but still not an expert by any means) is buying a keyboard without arrow keys and also, getting used to vim motions. Vim motions are amazing. People don't use them. If they did, it doesn't matter what the plugins did, you can use motions with fancy stuff that plugins provide. Also your argument against not installing an autocompleter is without basis. Just because vim can do it natively does not mean its good. The native suggestions are alright when I'm editing on a remote server but I use YouCompleteMe when possible on my own systems. People who are used to intellisense etc kinda need this to do their job and still use vim.
- fasoh 9y agoWhat helped me tremendously was remapping the arrow keys to resize my panes and splits like this: " Rebind arrow keys to resize panes (and force usage of home row) nnoremap <Up> :resize +2<CR> nnoremap <Down> :resize -2<CR> nnoremap <Left> :vertical resize +2<CR> nnoremap <Right> :vertical resize -2<CR>
- sleepychu 9y agoI've been using Vim as my primary editor (and vim mode in all my IDEs for something like 8 years) In my opinion knowing what lots of keys do in a modal editor is not that different to learning all the shortcuts in say an IDE. I learned all the shortcuts to use Eclipse very quickly when I stopped using a mouse (I've never really liked using them and avoid them at all costs) Pick a week where not getting a lot of typing out for time in won't hurt you. Stop using other editors. You'll forge the necessary pathways to use it with the proficiency you have in other editors and then you can look up the 1% subset of the enormous features that will actually improve your workflow.
- rando444 9y agoIsn't it difficult or limiting for you to try to navigate the internet without a mouse?
- gm-conspiracy 9y agoLynx, baby! https://en.wikipedia.org/wiki/Lynx_%28web_browser%29 https://en.wikipedia.org/wiki/Lynx_%28web_browser%29 Not everybody has perfect vision or motor skills.
- padthai 9y agoNot OP, but 99% of the time it is faster and it feels better. The only cases where I need the mouse are continuous interfaces (eg selecting an specific time in a video player) or restrictive and dumb webpage configurations (eg WhatsApp Web does noes not allow you to deselect the input box with the keyboard) I use VimFX and I would recommend it. It takes 2 min to learn.
- sleepychu 9y agoThis is exactly what I do!
- btschaegg 9y agoI've come to the same conclusions (I'm using Qutebrowser though). Interestingly, I found that my tolerance for the inefficient ways of most browser UIs now stands out to me as much as editors without Vim-bindings annoyed me after a couple of weeks. Once I got a hang of the controls, I started missing them everywhere else (unfortunately I can't choose my tools at work).
- mannanali413 9y agoI have felt that learning Vim, does have a direct relation to productivity, especially if you are more comfortable with keyboard interactions as compared to a GUI. And yes, the learning of this editor can be viewed as a developers investment into improving his/her productivity.
- JoshMnem 9y agoI learned Vim by taping cheat sheets on the wall next to my desk. Whenever I wanted to reach for the arrow keys or do something new, I would look over to the cheat sheets and find the right command. Avoiding the use of arrow keys helps speed up the learning.
- atmosx 9y agoEverybody is bashing plugins but vim without: - YCM - airline (I use inconsolata patched to have nice icons) - fugitive - Nerdtree - CtrlP - Utilsnips (I have some customs here too) - Syntastic (saved multiple times) And other plugins (ruby, go, latex, gist) would drop my productivity considerably.
- yAnonymous 9y agoThere's an abundance of good vim tutorials, but as a moderate user, it would be much more useful if there was a plugin that reminded me how to do things more efficiently. I know how powerful vim is, but forget the shortcuts or how to use them. For example, when I navigate words using H-L, remind me to use W-E-B instead. When I navigate many lines with J-K, remind me to use number shortcuts or G/gg. You get the point.
- throwawayvimmy 9y agoFor me I'd like there to be some "convention over configuration" package for Vim, especially with some modern shortcuts. I don't have Vim muscle memory so the aged shortcuts don't really offer anything for me. For example 0 goes to the beginning of the line, while ^ goes to the first character in the line. Why can't 0 be the "default" first character shortcut? Anyways I know there is a lot of Vim veteran out there that wouldn't want to use a package like this, and already have their own shortcuts made through years of configuration. It's just that there are hundreds of papercuts that would take years upon years for me to figure out and solve, instead of just learning. I'll just continue to use Sublime...
- icc97 9y agoI kind of felt the same way about Vim. I was very happy with Sublime. I still am and most of what I've done with Vim is replicate the functionality from ST. If you're not curious enough to dive in full time then stay with ST. I had the following reasons for switching: * it's open source * even if it is just 1-2% improvement that's a benefit you'll have every day for years - there's no guarantee but I wanted to see if it does help * as it's a command line tool it feels like you're closer to your code * you obviously get benefits in your SSH sessions * it does kind of feel like wearing a tailored suit, you set it up exactly the way you want it * I should be able to do everything that I could do in ST in Vim but I don't think it's the other way round
- hiq 9y agoDo you mean h-l? H-M-L are useful (top-middle-bottom of the window), but not to navigate words. By the way J (join lines) and K (look up the current word) are also useful.
- majewsky 9y agoI'll echo the recommendation for surround.vim, commentary.vim and repeat.vim in the "Week 4" section. These are my most valuable Vim plugins. I'd add https://github.com/ciaranm/detectindent https://github.com/ciaranm/detectindent and https://github.com/scrooloose/syntastic https://github.com/scrooloose/syntastic to the list, but esp. Syntastic may already be to fat for some people's taste.
- icc97 9y agoAll of Tim Pope's plugins are brilliant. One that saved me a ton of pain was his Obsession plugin which stores sessions that don't conflict as much with other plugins.
- Syssiphus 9y agoHow to learn ViM: Stop reading articles about how to learn ViM, and start using ViM.
- Zhyl 9y agoWhile I agree with this to an extent, I really feel that adopting any new tech/tool/language needs at least some motivation. To that ends, I think the best programming tutorial for the absolute-stone-cold "what even is computer code" is 'Automate the Boring stuff' [1] as it gives clear examples of where a computer doing something is better than manually doing something. The best vim 'motivator' is this stack overflow post [2]. [1] http://automatetheboringstuff.com http://automatetheboringstuff.com [2] https://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim https://stackoverflow.com/questions/1218390/what-is-your-mos...
- hakcermani 9y agoFor me these howto posts is the method the OP used. YMMV, but feel free to cherry pick ideas that may work for you. I skimmed the article and found some useful info on tabletop that I did not fully understand. But agree the best way to learn is to just use vim !
- epicide 9y agoSeriously. If you're completely new to vim, fire up vimtutor to learn the basics. From there, just start using it.
- taternuts 9y agoThat's my thinking as well. I printed out a cheat sheet, pasted it to my cubicle wall, installed VIM emulation in my IDE (I still think this is the best route for those used to their IDE's, provided it's a good VIM emulator), and haven't looked back.
- teolandon 9y ago> Week 4: Compose Vim commands with verbs and nouns Really? I discovered and abused this week 1, it's way too good, and the main reason I switched and stayed in vim. I would think "delete around word" and hit the keys, or "yank inside (", it works too well to be a week 4 feature to use.
- hestefisk 9y agoThe only real way of learning vim is starting with nvi (the real BSD Unix vi) for basic editing before going anywhere near vim.
- rocqua 9y agoThat would be learning vi now, wouldn't it?
- nameless912 9y ago....why? Nearly every server has real, honest to goodness ViM installed on it these days, and nvi is extremely limited in its capabilities by comparison.
- bolololo12 9y agoWhy should I learn VIM? I still don't get it, a sudden waterfall of articles about VIM>
- corpMaverick 9y agoIMHO. You need to know the basic vim commands in the case you are stranded in a remote server and need to modify a file. It is also handy to do quick changes to a file when you are in the command line. I used to do software development in vim back in the day, but I don't do that anymore. Now days I use sublime for scripts and an IDE for larger projects. My recommendation. Commit the basic commands to muscle memory but you don't need to be a power user.
- bolololo12 9y agoOk, so it's not that the dev community is moving from VS Code, Sublime to VIM, uff... In case I'm stuck I used to use nano. but like you say might be worth learning vim vasic commands.
- nameless912 9y agoHonestly? You shouldn't learn vim. You should learn a text editor, and get really, really, REALLY proficient with it. As programmers, one of the core skills of our job is to be able to manipulate text efficiently. After all, productivity is knowledge + tools + focus, right? All the knowledge and focus in the world doesn't help you when you're not able to efficiently do the mechanical part of your job. I chose vim because it's what I first learned in college. You might end up choosing Sublime, or Emacs, or even Atom. It doesn't actually matter all that much what you choose, so long as you hone the use of your text editor to the point where you can manipulate text without thinking about the mechanics of it. I like vim because it's built specifically for navigating through files quickly without any mental disconnect: moving through a file doesn't require me to think through the actual actions I want to take-I just think, and muscle memory allows me to do what I want. I like vim because it's consistent, the same keybindings always work everywhere in the same way. And I like vim because I really believe in the composable model used by its motions and actions; I feel like it allows me to very concisely express what I'm trying to do without me having to think about it. I also love vim because it automates parts of text editing that I find annoying: I'm a very heavy user of macros and custom functions because I have a lot of tasks that I repeat constantly and I've automated all of them. Can your text editor do all of that? Well, the answer is probably. But you should learn the deep intricacies of whatever editor you're using, just like a pianist might understand the exact sound profile of their instrument, or a chef knows the weight and sharpness of all their knives. It's our most important tool, and honing it to the sharpest edge we can is essential to becoming better. But that's just my (very philosophical and hand-wavey) opinion.
- konart 9y agoNow we need article explaining the 'why' part. I'm usring cVim for Chrome because that's a great wey to navigate pages. And I've got a VS Code plugin for more or less same reasons. Just a couple of 'shortcuts' for when I need to work on a large csv file or something like that. But coding? No. Still can't get it.
- maligree 9y agoI've had a completely different approach to learning vim, which I wholeheartedly recommend: - 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.
- antouank 9y agoOne thing I don't get, how do you navigate with hjkl when you're in insert mode? 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?
- levthedev 9y agoMany people rebind caps lock (or another easy to reach key) with escape. This way they can quickly change modes. 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).
- cujic9 9y agoJust switched to Vim after a decade of using Emacs. The switch was one part of a larger life goal to simplify and embrace minimalism. I think this shift in mindset was an essential part of being able to learn Vim. In Emacs, I had dozens of plugins, and I could do everything so fast that I almost went on autopilot. This was great for boilerplate code that's 90% typing and 10% thinking, but not great for complicated code (Haskell, low level machine learning stuff) that is 10% typing and 90% thinking.
- cup-of-tea 9y agoI don't understand why vim facilitates that workflow better than emacs. I have thousands of lines of elisp in my configuration files, but it'a all completely invisible if I don't call for it.
- cujic9 9y agoTrue, I could run a barebones [1] Emacs. But I want to align my use of the tool with the underlying ethos of the tool itself. I think of it as being similar to CISC [2] vs. RISC [3], or Chinese characters vs. the Latin alphabet. Emacs is CISC. It starts with a huge vocabulary of functions. If you intend to use it right, then you create new functions to add to the vocabulary. Eventually, it morphs into something that not even other power Emacs users can use. (The programmable editor.) Vim is RISC. It starts with a small vocabulary of compose-able commands. If you intend to use it right, then you learn to make increasingly complicated sentences out of that vocabulary. 1: For some definition of "barebones" -- Emacs ships with Tetris inside! 2: CISC - Complex Instruction Set Computer 3: RISC - Reduced Instruction Set Computer
- nemoniac 9y agoIn that case you were doing it wrong. With a touch of hyperbole you could say that emacs is there to do 100% of the boilerplate stuff for you so that you can spend 100% of your time thinking.
- cujic9 9y agoIf that were possible, then I would agree. But in my experience, automating the boilerplate stuff just tends to expand the domain of what can be considered boilerplate stuff. If I can rename a class across my project in 3 keystrokes, then I've automated it. But then I'll try out a dozen names before settling on something. Have I saved time? Perhaps I'd be better off thinking deeply for a minute or two instead. It's kind of like how Powerpoint has actually increased the time that people spend making presentations. "Look! I can change the title font in one click!" <Spends the next 2 hours fiddling with fonts.>
- rocqua 9y agoI'd add the recommendation to disable arrow keys in .vimrc It forces you to learn hjkl, and thus helps keep your hands on the home row.
- cup-of-tea 9y agoFour weeks is a lot of time. One could learn many things in four weeks. Why would someone decide to invest so much time in a text editor. And, specifically, why this text editor?
- baldfat 9y agohttps://www.norfolkwinters.com/vim-creep/ https://www.norfolkwinters.com/vim-creep/
- diskape 9y agoHonest question: why?
- jmcqk6 9y agohttps://stackoverflow.com/questions/597077/what-are-the-benefits-of-learning-vim https://stackoverflow.com/questions/597077/what-are-the-bene...
- emivvv 9y agoI love this vim comeback.
- baldfat 9y agoMaking your mouse a dust collector is key. I use qutebrowser for internet Ranger.py for file manager I also use a tiled window manager (i3) The only time I use the mouse is when I am doing creative work (video editing, graphics or music production) I use VIM bindings in R Studio and VS Code and I am actually using less of VIM and more of VS Code strangely.
- southphillyman 9y agoI work with several "Vim masters" who do about 50% of their development in Vim and 100% of their file editing there. It's extremely embarrassing to have to sneak and do repetitious file edits by hand in Notepad++ because I never invested the time into learning Vim. I tried reading a Vim book but became bored and quit after a chapter or two. Honestly I never worked with people who use Vim everyday before so it doesn't seem to be THAT common where it's a requirement to know it but I guess it's worth giving it another try.
- marktangotango 9y agoNotepad++ does a few things I really like and haven't taken the time to learn how to do in vim. In particular, double click and highlighting a word and having the word highlight in the entire file, and then scanning the whole file by scrolling with mouse. This is stupid but I do it all the time when working with unfamiliar code bases.
- yodsanklai 9y ago> It's extremely embarrassing to have to sneak and do repetitious file edits by hand in Notepad++ because I never invested the time into learning Vim. Nothing to be embarrassed of. Vim isn't the graal of editing and people are productive with all sorts of editors. Actually, I'm pretty proficient with Vim but I'm starting to wonder if it wouldn't be better to focus on standard mac os shortcuts. And I also believe that the best programmers are those that type the less...
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- sevensor 9y agoBeing able to do more with your text editor is one reason to learn vim, and it's the theme I see over and over in these "learn vim" posts. But it's also responsible for the idea that, in the words of the article, "learning vim is a lot of work." It's just not true that learning vim is a lot of work -- learning to do a lot of things with vim is a lot of work. But basic hjkl navigation, switching between normal and insert mode with i and ESC, saving and exiting with :w and :q, deleting text with x and dw, these take a day to learn, tops. Learning the basics pays off right away, but it doesn't pay off in terms of being able to use advanced features. There's an alternative reason to learn vim that I never see anybody mention. Vim allows you to think less about your text editor. Once the basic editing commands become automatic, vim puts the least friction between your brain and your text. No mouse, no arrow keys, your fingers mostly don't stray from the home row. (Especially if you learn to use ^[ for ESC.) It's as big a gain as learning to touch-type. The productive insights accumulate with time. It really doesn't matter to the beginner that dw composes a command and a motion. It deletes to the start of the next word, and that's enough for now. The idea that you don't actually know vim if you don't understand its grammar is ridiculous. It's like saying that kids can't speak English because they haven't learned how to diagram a sentence. The whole "learning vim is super-productive but super-hard" narrative is just condescending ego-stroking from people who already know how to use it. I suspect it's actually discouraging people from learning vim, which isn't actually very hard. Half a dozen commands, and one crucial concept -- normal mode -- and you're off to the races.
- icc97 9y agoIt is super hard because everything you're used to from your regular editor or browser commands don't apply. So all your muscle memory is useless. That might sound like it's easy to overcome but it's not and it's super frustrating until you get out of one groove into the other.
- sevensor 9y agoI think a huge reason people find this difficult is that it's being presented alongside a whole bunch of other ideas. Even the fairly minimalistic vimtutor goes off the rails after lesson 1. Most of the stuff in that tutorial could wait until you've been using vim for a month or longer. Learn the movement keys, learn to enter and exit insert mode, learn to delete text, and learn to save and quit. Trying to learn that and at the same time trying to learn about how commands are composed of actions and motions, or how to use plugins, or buffers, or regex, or anything else, is going to cause you to stumble over the basics.
- u801e 9y agoBack when I was in college in my intro to Unix class, I was introduced to vim as a text editor as part of the course and learned the basics. Over the next several months, I read through the getting started and editing effectively sections of the main vim help page and got up to speed. In my opinion, just reading through the documentation and practicing is really all that you need. If you want to become an advanced user, then you need to always think if there's a more efficient way of doing something in the editor that's currently rather tedious and, once you learn it, practice and commit it to memory.
- hashkb 9y agoFor me it was just a week until I was as good as I had been in sublime; all uphill from there. Now I have to use all the time I save to mop people's drool off the floor behind me.
- taw55 9y agoIf you need 4 weeks to learn a text editor, this might not shine the best light on your editor’s ui.
- blonky 9y agoI learned vim by trying to learn Ruby/Rails(my first experience with programming). It got tedious to open files by looking them up in the Mac Os Finder. Then one day, someone showed me how to tell an application to open a file via the command line. I'm a noob. Vim found its way into my workflow, and I haven't looked back.
- vram22 9y agoFor anyone who is looking for a smaller vi tutorial (vi is the predecessor of vim), or just to dip their toes into the water initially: Here's a short free vi quickstart tutorial that I wrote a while ago: https://gumroad.com/l/vi_quick https://gumroad.com/l/vi_quick With this tutorial you can learn some basics of vi (which is the predecessor of vi) and get up and running with it in an hour or two of practice. Learning vi commands (the subset that does not belong to vim as well) is useful because vi is probably more widely available than vim (since it is more lightweight and also comes installed by default with many Unix and Unix-like systems, and even some non-Unix-like systems. So, having vi skills in your toolkit, makes it possible for you to edit text files with ease on a very wide range of operating systems, without needing to learn a new editor for each one or every few ones. I first created it for some colleagues of mine at a company where I worked earlier. They were Windows system administrators who had been given additional charge of a few Unix business server boxes. I wrote it at their request. They used the tutorial, and then told me it helped them to come up to speed with the basics of vi quickly, which helped them manage those Unix boxes. I later published the tutorial in Linux For You magazine (now Open Source For You), an Indian print-format computer magazine. Enjoy, and feel free to give me feedback via Gumroad or the email in my HN profile.