9 ms·
Learning Vim incrementally (2010)
- Phenix88be 7y agoI started learning Vim keybindings (on Spacemacs) when my extensive 8h/day use of the mouse had becoming painful. Some days I could barely move some of my right hand fingers. One day I had enough, I started the Vimtutor process and never looked back. No more pain since.
- raverbashing 7y ago> To those who would say "that's obvious; of course you learn vim incrementally", I would simply say that having spoken to a number of vim users in the past, I never got that advice. Instead, I got a lot of advice about turning off my arrow keys, disallowing the use of the mouse, and learning the (MORE EFFICIENT!!!) vim ways to do everything, all at once Ugh, this. Arrow keys have been invented for a reason, they're good and intuitive and there's absolutely nothing wrong with using them. Same with the mouse. The "pure" VIM ways are more efficient than ed. They're maybe more efficient some 10% of times you actually need some specific thing. But they're not better than a visual editor.
- Lio 7y ago"Pure" vim supports cursor keys, mouse, windows, syntax highlighting, fuzzy searching for files, filetree and a whole host of other features without the need for plugins. In what way is Vim not a "visual editor"? The main problem with using Vim is that you will spend a bit of time explaining to those that don't know it very well that it's actually perfectly capable of doing the thing they are using as justification that you should switch to their current favourite IDE/editor... :P
- awwaiid 7y agoI config vim to have a slightly different semantic for arrow keys vs hjkl. I leave hjkl as-is, and then make arrow keys move across visible screen lines. So if there is a long line that wraps, the down arrow moves down one visible line (so technically still within the long line), and j moves to the next actual line in the file. Handy. map <up> gk imap <up> <c-o>gk map <down> gj imap <down> <c-o>gj
- UI_at_80x24 7y agoThere are two (non-exclusive) camps for vim use. Developer and Admin. Most of the discussion here focuses on the dev-side of things naturally; but I want to touch on the Admin/sysop side. If you are just starting out editing config files there is very little benefit to using vim over some more simple (i.e. nano) Example: Editing an sshd_config file. Scenerio: You want to change the default port number that sshd is listening to. Both nano and vim make this singular task very easy and quick. As far as speed goes, I'd say they are close or equal to each other to finish this task. Where vim really shines is for larger and more 'annoying' tasks. Example: You need to iterate out a list of incrementing IPs for another service. e.g. 192.168.0.1 192.168.0.2 192.168.0.3 ...etc... 192.168.0.254 In nano, you need to manually edit/add each line which is combersome; however with vim there are multiple ways of doing the same thing (recorded macros are amazing!). But in my experience the hands-down "it doesn't get better then this" 'Admin use' of vim is this: editing YAML files (whitespace is evil, OMG why?!?) vim can be configured to convert your tabs to spaces and all pain is ended in the universe. Little things add up. For the odd small job, you might not see an improvement over a 'dumb' editor like nano; but the skills you learn on the small things translate into big improvements on the big jobs. P.S. Being able to edit your editor is a HUGE benefit too. My company wants us to keep detailed track of our time-spent on each project. So I added a hotkey (F5) to input the date/time-stamp whenever I start/stop a task. Consider this analogy, nobody needs to modify their .bashrc file or create custom aliases. But look at how much you suffer when your customizations are not there. You don't need to use anything more then nano, but the improvements scale exponentially when you do.
- wodenokoto 7y ago> vim can be configured to convert your tabs to spaces and all pain is ended in the universe. Every editor more advanced than notepad can be set up to do this. Personally I don't want to do this for every single text file format I might come across. Being able to add weird, personal features does sound cool though.
- ptah 7y agoflame bait
- seren 7y agoThe content of the article itself is not that shocking, it only says instead of learning all commands & tricks at once, it recommends to learn gradually.
- jplayer01 7y agoI assume he means the title. It's clearly clickbait at the very least.
- _4570 7y agoMore like clickbait. Reading the title might give you the idea that using Vim is wrong. The article then proceeds to tell you that how people get started with Vim is wrong.
- jplayer01 7y agoI don't think a site like HN should be rewarding sites for using clickbaity titles. Maybe it's just me.
- makach 7y agoVim is a tool like any other tool. Well, a powerful tool. Having a good editor is essential when working with text. For any task pick the right tool for the job. An expert task requires expert tools. There are many good expert tools. Pick your poison.
- alfonsodev 7y agoThe post is from 2010, today in 2019, I'd say that first step could be to install a vim extension in your already existing IDE/editor, VSCode and Idea have good enough vim plugins to start learning insert mode and moving around, and even allow you to search and replace :%s/termA/termB/g You can also play Vim Adventures[1] if you want to be even more playful. [1] https://vim-adventures.com/ https://vim-adventures.com/
- growt 7y agoThe vim extension for VSCode even has macro recording!
- StavrosK 7y agoUnfortunately I've found that vim modes for various editors are good enough to fool you so you keep using them, but not good enough to not frustrate you with the differences. In PyCharm, for example, I have no idea how to use any keyboard shortcuts with vim mode on, since vim then absorbs the keys pressed and I lose all keyboard access to the functionality.
- JNRowe 7y agoI have the same experience, but I'm yet to decide what is worse: weak vi-mode where it collapses straight away(no count support fex), or strong support where it fools you for long enough to catch you out when you're fully in the flow. My go-to example for strong support is emacs' evil-mode¹, it takes a lot for it to break down. For example, it even supports things like the expression register² but then requires an elisp expression. 1. https://bitbucket.org/lyro/evil/wiki/Home https://bitbucket.org/lyro/evil/wiki/Home 2. https://vimhelp.org/insert.txt.html#i_CTRL-R_%3D https://vimhelp.org/insert.txt.html#i_CTRL-R_%3D Edit: I'm pointing out where it has fallen down for me, not complaining that the devs haven't implemented a full vimscript interpreter to attach to that binding. I love evil.
- jplayer01 7y agoThe great thing about spacemacs/evil is that generally all the standard emacs bindings work how you'd expect them to. I can still M-x and get access to everything emacs.
- golergka 7y agoWhen I switched to Vim, I was at 1/3 of my usual productivity for the first week, and I think at about 1/2 for the first month - author is completely true about that. However, since then, I've been so much more productive over next 7 years that it had definetly been a good decision. And I don't even use Vim now! Visual Studio, VS Code, all JetBrain editors have competent vim emulation plugins, so the core of my ehnanced productivity, the core and most important feature of Vim, is still paying off. I just wish I had a spare year to learn and configure Emacs. (Yes, I have tried Spacemacs and other options, many times, and it was so confusing every time that I only believe in learning Emacs from absolute basics withut any plugins now).
- nineteen999 7y agoWait, VS/Code both have vi emulation plugins? I wish I knew this a couple of years ago ...
- golergka 7y agoAny modern editor with a decent plugin ecosystem has one, and while VS/Code is not ideal, it's certainly workable.
- nineteen999 7y agoGood to know, thankyou. I usually only use VS on Windows for C++ with Unreal Engine, usually I'm a Linux/BSD minimalist who uses vim. I wonder how well the vi plugin for VS works alongside Visual Assist X, which is the only plugin I currently use for VS. I'll have to give it a shot when I get some time.
- golergka 7y agoNever used Virtual Assist X, but the plugin for VS (not VS Code, just the good old VS) is one of the best Vim plugins out there.
- Pimpus 7y agoLearning a good editor is an investment. You sacrifice some productivity and time now for a massive return on your investment later. Stating the obvious, I know, but so is this article.
- megous 7y agoTrue. I was using mcedit for quite a while, until I one day had a short contract with one of the better known Czech programers and saw vim in action in skilled hands. It looked like magic. I started learning it shortly after, despite being in time press at the time. It helped immensly. Just navigating around the code was amazing. Macros, repetition of the last edit action, increment/decrement a first number after the cursor, block editing, lot of tiny stuff that is just so good when combined. I even wrote a bunch of vim code to help writing GObject C code, when it was still boilerplate heavy back in 2006.
- DictumMortuum 7y agoI keep reading about productivity on vi vs other browsers. That's cool, however the thing that makes me want to use vi with proficiency is another though: availability. I spend a lot of time in ssh or docker sessions and not knowing vi can severely hinder my job.
- nineteen999 7y agoThe thing is, if you were a user of multiple different UNIX systems the previous century, it was much the same - vi was the only editor installed out of the box on all of Solaris, BSD, Tru64, AIX, HP-UX, Linux etc. So if you were frequently moving between them as some of us were, you wouldn't get very far if you didn't know at least the basics of vi.
- dusted 7y agoOh, can I resist.. Nope, sorry. Everyone who tried to convince me to use vim plugins was wrong. Keep it clean :) Vim is my daily driver for programming, which is my job, in my office we're 2 using vim, we exchange tips and tricks sometimes, and ask questions that are exceedingly specific, and it just becomes nicer and nicer to work with text as I get better. I do need to experiment with multi-line cursor, that I mess from vscode studio. The article is well written, and the authors has a good point. I don't think there are that many situations where "dive in head first" is that good of an idea.. Slip in where you can find ground, and work your way out until you learn to swim. I'd never switch off my cursor keys, I don't CARE if it's supposed to be more efficient. That's how I feel right now, maybe one day, I'll feel different, but if I do, I won't recommend any new users to do the same, that's just silly.. I mean, that'd do nothing but scare them away and make their lives miserable.
- tomcooks 7y agoNo idea why you're getting downvoted I'm very much against plugins as well, being able to reliably work on a vanilla vim install allows me to productive everywhere. But yes, I do miss the multicursors I've learned to love on Sublime Text.
- Lio 7y agoI have try to be able to use both. e.g. I know how to set up a path and hit search for files but I find FZF to be better. I know how to use Netrw to show a file tree but I prefer the look of NerdTree. I also often use ctags for navigation but I'm using coc.vim plugins more and more to get code aware LFP features. Generally I try to avoid custom mappings though so I'm closer to vanilla vim when I need to be.
- dhagz 7y agoWho needs multicursors when you have macros?
- tomcooks 7y agoHow would you use macros to simulate multicursors?
- collyw 7y agoI can do the very basics of VIM (like exit it). Can anyone tell me what I would gain over Pycharm (when most of my work is done there) as the learning curve seems steep?
- mikorym 7y agoThis may be a useful or a detrimental comment, but I would say if you see yourself as a developer, then Pycharm may win out. If you see yourself as a more low level coder then vim may win out. The main advantage of vim to me is homogeneity across different platforms and languages. Oh yeah, and the next question is do you love your terminal? Are you the type of person that would browse the web with your terminal and write ToDo lists in your terminal? If not, again Pycharm may be the preferred candidate.
- kd5bjo 7y agoThe main benefit is that the effort to learn Vim is transferrable to other programming languages and environments. Editing a config file over SSH is the same as working with Python is the same as working with Javascript. This gets especially convenient if you work with multi-language projects, where you would otherwise find yourself switching between programming environments for a single task.
- kace91 7y agoAs for what do you gain, it's basically the same jump as copypasting by using ctrl+c/ ctrl+v vs. using your mouse to go to the top bar and clicking edit-> copy then edit->paste. What I mean is that it's one of those computer skills that, after you learn it, even watching over the shoulder of someone who doesn't use it is painful. As for vim vs pycharm, I wouldn't advise to switch. I would advice to find vim emulation for your current editor (vscode's is superb).
- Lio 7y agoI think this is possibly the wrong way to look at it. Both Pycharm (and the JetBrains core IDE) and Vim have large feature sets and those feature sets can be extended via plugins. So saying what you would gain from one to the other is not straight forward. You gain some things and loose others. For example Vim keeps it's undo system as a tree whereas most GUI apps keep their undo commands as a stack. i.e. if you have series of edits and you undo 2 and then make a new change the other two edits are lost. In Vim they aren't, the tree of edits can be navigated at will. Assuming that undo tree is a useful feature to you (it is for me) I'd have to do a good search of Pycharm plugins before I can say it's a definite advantage of Vim. Equally you might find that Pycharm has some code aware feature that Vim can't provide via an LSP plugin or VS Code extension in which case you'd want to stay using Pycharm.
- badsavage 7y agovim is still the best text editor, our whole family uses it for daily work
- xtiansimon 7y agoHaha! I love it! Family that VIMs together...
- roland35 7y agoThere is probably an eccentric uncle who uses Emacs though!
- ptah 7y agook, i'll bite: you need to learn vim if you are ever going to edit stuff remotely on a vanilla unix/linux/bsd server
- majewsky 7y agoI agree with the article, but I'd like to add another early step: Understand that Vim's normal-mode commands are like a language with nouns and verbs. You can mix and match most nouns (motions) with most verbs (actions). So when you already know 5 motions, learning a new action actually means learning 5 action-motion combinations at once. With this in mind, observe yourself as you work and notice which motions and actions you need most (like `ci"` in the article). Focus on these at first for those sweet sweet quick wins.
- melvinroest 7y agoThe following has been repeated quite a lot on HN, but for people who are new to vim or new to reading HN it bears repeating. 1. Go to your terminal. 2. Type in vimtutor. 3. Spend half an hour. 4. Congratulations! You are now able to survive in vim, while you're by no means a master yet, you're probably around 80 to 90% as productive in vim as with a general text-editor without plugins. IMO it's 30 minutes well spent.
- deleted 7y ago[deleted]
- Lio 7y agoThat's the simplest and best starting suggestion. I'd follow it with watching some editing videos on http://vimcasts.org/ http://vimcasts.org/ and by reading Practical Vim[1] gives a really good set of editing recipes in "pure" vim without plugins. Finally I'd also suggest the follow up Modern Vim find out about plugins and LSP support.[2] [1] https://pragprog.com/book/dnvim/practical-vim https://pragprog.com/book/dnvim/practical-vim [2] https://pragprog.com/book/modvim/modern-vim https://pragprog.com/book/modvim/modern-vim
- YeGoblynQueenne 7y agoI think the point of the OP was that they don't want to have to memorise a whole bunch of new commands before they can be productive with their new editor. This makes a lot of sense btw. Think of all the commands and shortcuts you need to know to be productive and quick in everyday programming work: OS shortcuts; terminal commands; git commands; IDE shortcuts; and now, a whole bunch of editor shortcuts _and_ commands. And, does vim's interface help you very much with remembering what you should type in to do what? Sometimes, yes (:w(rite); :q(uit);: x(it); :w/q/x/a(ll); etc). Sometimes, not so much, no (hjkl wtf? :y? :o? Is that a smily face?). And how much of that stuff in vimtutor are you going to use in the first week of use? 10%? 20%? 50%? The rest, you'll just forget immediately anyway. So that's half an hour that you probably can't afford and that you definitely don't need. So taking it easy and not trying to learn a whole bunch of stuff you're not sure you need is very good advice.
- 7y ago
- roland35 7y agoThe best part of learning Vim is being able to load it into almost all IDEs such as Eclipse and VS Code. Even though those implementations are incomplete and slow versus stock vim, it makes navigating and modifying text much easier. I just wish there were better guides managing plug ins for Vim in Windows! I have trouble with the new Vim 8 plug in system.
- ShteiLoups 7y agoYou could install WSL and have native VIM in bash in a distro, with the normal Linux package management solution.
- monadz 7y agoI have tried this, and it was very slow. I have had better luck with gvim or neovim-qt
- pesarkhobeee 7y agoOne of the possibilities for people who already used sublime or vscode is giving a try "Oni Editor", it is based on neovim and Also have a really nice tutorial section which you can collect some achievements : https://github.com/onivim/oni https://github.com/onivim/oni
- kanokun 7y agoI switched to vim I was unproductive for days and frustrated. Then I realised I don't have to go thorough this pain there are so many great IDE's out there. 10 years later I am still super productive and don't use vim.
- noobiemcfoob 7y agoVim isn't a silver bullet to productivity. Here's a parallel story: I tried Emacs. I was frustrated and confused and felt stupid. Then I realized I had so many other tools at my disposal, I'd just use those instead. Here I am, 10 years later, happy and not feeling stupid at all! ...but I don't know Emacs. And don't feel compelled to offer my experience on Emacs other than I struggled to learn it, but plenty seem to find it amazingly powerful. Good for them.
- elagost 7y agoI'm convinced that people who use solely vim/emacs started off before there were any good GUI editors and now have too much momentum. I'm not that old, but I frequently spend time on headless *nix boxes, so I use vim all the time and love it. I have a portable .vimrc that I take around with me because I have spent so much time that I want to configure things the way I like them. Despite my love of vim, on the desktop, I fall back to gedit or Notepad++. Vim and Emacs are great editors when you're SSH'd to a headless server, but they will not replace an IDE (or even TextMate). That is completely ridiculous.
- Cakez0r 7y agoVim was before my time, but I learned how to use it after seeing in videos how blazingly fast people could edit text inside vim. I had already put hundreds of hours into Visual Studio by this point, so I installed a vim emulation plugin and haven't looked back since. I've never used vim-proper as my daily driver, but I can use it well enough thanks to cutting my teeth with vim emulation plugins in more modern editors.
- noobiemcfoob 7y agoI'm the counterpoint to that belief. I started programming professionally in 2010, learned vim around 2012. My work environment was just better suited for a command line editor and it was nano, vim or emacs. Vim won. Since then, I'll have a constant itch to get vim bindings in whatever editor I'm using. At the time I switched, I'd been using Notepad++ and loved it. These days, my graphical editor is Sublime (of course with vintage mode enabled). Vim with just a handful of plugins is a complete IDE. Vim alone is an editor.
- nicolashahn 7y agoWhat features are you missing? Are there no plugins for them?
- lunchables 7y agoReally curious to hear why vim cannot replace an IDE or TextMate? Maybe it depends on your very specific use case? I certainly replaced my IDE(s) with vim and some plugins. I'm a vim user, certainly one who was alive long after "good GUI editors." My first programming was done in Visual Basic over 20 years ago.
- YeGoblynQueenne 7y ago>> Turn off your arrow keys. This has gotta be the worse piece of advice I've ever heard in my life, second only to "why don't you march towards my line?" [1]. I've been using Vim for umm, eight years? Thereabouts. I never turn off my arrow keys. How much time are you supposed to save like that? Milliseconds? You go much faster with B, E, Crl+Y, Crl+D anyway. Just misguided advice from otherwise well-meaning folks, that's all. Edit: btw, how do you go through your recent command history on vim without up and down arrow? Do you have to q: and navigate with hjkl every single time? Is that more productive than pressing up arrow three or four times? _____________ [1] Sorry guys, Warhammer Fantasy Battles reference there. See, I got a shooty Dwarf army, he's got a shooty Empire army, so we're standing just outside each other's range and scream insults at each other. His light cav mauls itself on my Slayers trying to flank my Thunderers (yeah, I don't know what he was thinking, either). He's got a Steam Tank, but I got a Lord on a shield (with a metric shitton of runes) protected by a regiment of Ironbreakers (with a metric shitton of runes) on the Tank's side. So noone's going anywhere in a hurry. So, by way of friendly advice, he says "why don't you march towards my line?". Yeah, right. So your Sniper can pick out my Lord and your Tank and Knights can sanswich my guys? You kiddin'? Btw, he did win anyway. It turns out you gotta make _a lot_ of saves against a well-designed Steam Tank. Also, I suck at aiming artillery. But, come on. "Walk towards my line"? Do I look like an Elf or something?
- OskarS 7y agoI read that piece of advice when I started using Vim, and I'm very happy i did exactly that. If you're skittish about using Vim in the first place, then sure, it's a pretty bad idea to tell someone to disable arrow keys, but for someone that's determined to learn how to use Vim, it's great advice. The point isn't to save time (though using hjkl does that for sure), it's to make sure your hands never leave the home row, which they ideally shouldn't do very often when using vim. It makes them more natural to use for composition: "c3h" is much cleaner than "c3<left arrow key>". Also: if you become an "intermediate/advanced" user, you use these keys much more rarely anyway: I use "w" and "b" far more often than "h" and "l" to move inside of a line, as an example. Breaking your dependency on arrow keys makes this transition easier. Besides, it frees up four arrow keys on your keyboard up to do all sorts of fun stuff with! I have mine bound to switching windows (so "left arrow key" is moves focus one window to the left), and with modifiers they create window splits. Makes using windows in Vim a breeze!
- meuk 7y agoVim is quite nice, but also quite... old-fashioned? I use vanilla vim as my main editor. Today I had to search for some text verbatim, and I don't think there's a way to do this in vim: It treats everything as a regex. I'll also happily use mouse support, and really hate the bad support for the clipboard in vim. I have spend multiple afternoons on getting this to work properly and it still doesn't. So sometimes you just have to take your loss and use another editor for something.
- deleted 7y ago[deleted]
- YeGoblynQueenne 7y agoYou can search for a string verbatim, but you have to remember to escape special characters. Is that what you mean? That the special characters have to be escaped?
- ej12n 7y agotreats everything as a regex by default but you can turn it off easily... /\Vwhatever... see :help \V you can also use \< and \> (beginning of word, end of word) for easier phrase matching... /\<my phrase\>
- denton-scratch 7y agoI never knew you could use a mouse with vim. I've only ever used it in a terminal session. I can't understand why anyone would use an editor designed for a terminal if they have a GUI. [Actually I mainly use vi, but I believe it's the same program]
- 7786655 7y agoIt's useful for resizing splits and scrolling.
- grandep 7y agoMany people, myself included, prefer to work from the command line over navigating through highly constrained, clumsy GUIs. For those people, an editor designed for the terminal is a feature, not a bug.
- denton-scratch 7y agoPoint taken; I'll start a terminal to launch vi over using a GUI-based editor. I like many of the Jetbrains editors; but for a small job, if I don't have Idea running, it's quicker to launch a terminal.
- ShamelessC 7y agoI think the authors use of MacVim makes mouse integration better supported than terminal vim.
- Zelphyr 7y agoI've been using Vim for over 20 years yet every time I read an article like this I learn something new. How did I not know about `ci "` until now?!