If you expect everything to be completely apparent to you the first time you look at something, that says more about your approach than the value of the tool.
All these abstract claims in blog posts and on forum pages about productivity are completely worthless. Go watch a stream where you can actually see someone program. Maybe you'll pick something up that they do better/faster/more elegant than you. Other than that, the best advice is to ignore these kinds of topics.
If I am working with another expert vi user it is very easy to give him precise instructions - I can just say things like replace the second foo with bar on every line starting with a space and he'd know to type the correct : incantation.
The key is to pay attention to your inner voice saying "there has to be a better way" and doing something about it! Bottom line: learn to know how to use your everyday tools well.
The whole "Vim gives me amazing productivity" thing seems to be a personality trait: People telling you this are much more positive wrt tooling than I am. My basic gist is more like "why the hell can't I do X with this tool". I only started recognizing Vim's worth after getting more and more frustrated at other tools because they seemed to slow me down. Funny enough, I had the exact same experience a couple of years earlier after I got reasonably accustomed with Linux and Bash/ZSH. Learning them was more or less "meh", but coming back to Windows is a nightmare for me now. You have to do everything via the mouse, and the terminal seems almost unusable for me - it's not that I am amazed at how great my tools are (which, to be fair, they actually are), but I get very angry at any tool that doesn't at least do a decent job.
Luckily for me, this effect only seems to affect my experience with tools. I still can get very excited about APIs and programming paradigms :-)
That's not to say that other editors lack a meta-language. Even Notepad has Control-this and Meta-that. But vim and emacs (and my new favorite, kakoune) are all about using the meta language to manipulate text as much as possible, and only doing text entry when text entry is truly called for. Subjectively, I feel more productive using one of these, and completely hamstrung by IDEs, even when they supposedly support vim keybindings.
I see a couple of interesting parallels there - the biggest difference of Vim's modal commands to other control schemes (except maybe Emacs') is that they compose rather well. Add macros to that, and you can define (more or less) abstract editing functionality on the fly. It's basically a similar thing to what Lisp did to ASTs with it's homoiconicity and the macro system on top of it...
When programming, you spend comparatively little time actually writing code. The vast majority of the time is spent reading existing code, and most of the remaining time is modifying the code you read. It actually pretty rare that you sit down and write an entire method or class in one go.
Most editors, however, always have you in the writing state: Just about any key you press will be added to the file you're looking at. If you don't want to add characters to the file, but still need to do things, you need to add modifier keys like Ctrl or Meta or Ctrl-Shift-Meta to the actual key. To move around the file, or between files, or search for more code, requires these longer chords of keypresses. To edit small bits of code require more chords. As such, the things that you do most of the time (reading, modifying) when coding require the most complicated keystrokes.
The default "mode" of an editor like vim is reading. Nearly all of the keys you can press in that mode are just to move the view around or switch files. Eg, the keys to move by a single character (`jkl;`) are all on the home row. To move to the next block of code is simply `]`. To jump to a specific character is `f` + that character. To find some string is `/`, and then `n` jump between matches. And then to copy/paste some code is just `y` and `p`. In any other editor, all of those actions would require one or more modifier keys. So in my mind, vim's primary advantage is that the sorts of things you're doing when coding take many fewer keystrokes, and hardly any modifiers that contort the hand.
And then on top of that, all of the actions one can take in vim can really be thought of as functions that take arguments. So you can use the "copy" action with any movement action (char, line, paragraph, find, etc...), and that's the part that will be copied. Prefix an action with a number, and it'll be repeated that many times.
It's this mindset that few other editors can manage (and even the vim emulators miss some of the really cool stuff), which is why they have have my vim when the pry it from my cold, dead, carpal-tunnel-laden hands.
> [4] Or, emacs. Or, really, any other tool that you 1) use constantly; 2) is almost universally applicable; and, 3) makes you more productive.
Nice to see consideration for other tools in a piece like this.
I put VIM in the title because 1) it's got a recognizable identity to pull in readers and, 2) I use VIM. But, in a weird and almost recursive way, editor wars are kinda like language wars. If it gets you that 5% (or more) boost, great! But, the differences between them often washes out.
But learning Vi is extremely useful, because many editors/IDEs feature a Vi Plugin:
Visual Studio, Qt, Eclipse, Xcode, Atom, IntelliJ and of course Emacs. Learning the basic Emacs shortcuts is likewise useful for terminal (though some shells also have a Vi mode!)
Very recently I was a pretty staunch advocate for IDEs and thought the whole VIM situation was crazy. It is unintuitive. It doesn't come bundled with lots of useful tools. It takes some configuration if you want nice things (e.g. file tree on the side).
Over winter break I decided to really commit to becoming productive in VIM. I stopped using VSCode and I stayed away from other IDEs, even as I was learning Java Spark and digging into some Python projects.
I didn't notice it at the time, but VIM has made me much more productive, even with my very minimal knowledge (I learn new commands even for basic things all the time). Ultimately, the fact of the matter seems to be that the keyboard->mouse->keyboard transition is really slow. Going to Visual Studio (I'm learning Win32 and I don't want to do that without IntelliSense) after ~2 months in VIM is almost excruciating. I'll be loading up the VIM plugin pretty soon
The long and short of it is, and my advice for everyone who asks is, learn VIM (and other command line tools) as soon as you possibly can. I have no loyalty to the UNIX philosophy or ecosystem, but take it from me, you'll be glad you did.
I mean, I understand it's attractive to a programmer's mind to be able to do fancy 'replace the next 3 words with x' and so on, and compose them in vim's language, but if I am deep in an algorithm the last thing I want is to have to context switch to "programming my editor"
When doing editing tasks in a more visual as opposed to programmatical way, it feels more that my "coding brain" is free to continue working on the algorithm at hand while some other part of my brain deals with the moving of text around.
Keeping the right cursor key pressed for 1 second is a lot slower than doing some fancy move to the X word in the line, but if engaging my brain to create the composite "move to the X word" command takes me out of the "flow state" I am in, it is way way way more expensive in the long run. In the end what you want is to be the most productive, and the most productive could mean that you are using the editor less efficiently because the more efficient parts of your brain are busy doing something else.
Not sure, maybe somebody that started with vim as their first editor does not have this context switching issue, I personally started with emacs and remained with it and I have my emacs config full of hyper / super / meta / alt / control / shift shortcuts and tons of cool packages, but while I am deep in coding flow state I still use the cursor keys with minimal package help (outside of multiple-cursors and macros sometimes) to avoid getting distracted.
I'm sure there's something to get out of being an "expert Vim user", but even if you're starting out, there's already much to be gained from the simple routines. I find the notion of a "Vim Kata" very compelling as a metaphor, since it's really the repetition that teaches those "reflexes" at first.
I don't know how much an avid Emacs user could get out of it though. I guess that comes down to personal preferences. I couldn't get myself to memorize all the weird key combinations for example, but I quite like Spacemacs' mnemonics system.
I think the transformations you think about map very nicely to vim commands. If you want to move some code around for instance, the action you want in the brain is "delete line" and the vim mapping is "dd". So I'm never thinking about vim commands, I just have an internal mapping for the change I want to the command to do it.
This is where I find the productivity comes from, with a normal editor you go thought->action, thought->action, etc and I find if action is to long it can break the thought part.
I think this is actually the source of the "steep learning curve" problem. Once you've used it enough, it is an almost orthogonal part of your brain that does thats the VIM command-ing. It becomes more like, "to walk, put one foot in front of the other." You don't actually process that thought when walking.
But, until that point, it absolutely IS the same part of your brain. Until that point, there IS a PAINFUL contention between work brain and editor brain.
Vim is awesome. It's not an editor - it's a lifestyle. It's telling the machine who's the boss. It's staying "in the zone". It's cutting through the code like slicing butter with hot knife.
So, one day I woke up. I realized that Emacs can be better Vim than Vim. Hold on. Before throwing stones at me do one thing: give an honest and heartfelt try to Spacemacs. I guarantee it - you will be amazed.
Author presumes 100% of programming time is spent typing/editing.
Is this really the case? I'd wager it's close to 10% for most people.
I'd love to see some objective stats though!
Reducing the number of keystrokes per days is paramount to productivity increase for me, nowadays.
So what's kept me from going 100% vim?
1. Plugin/add-on support - I have no clue what's going on here. There's no clear guidance on what to use (vundle? pathogen?). I haven't really grokked how plugins really work - where do they come from? how do I search for them? where are they really installed? how are they organized in the install directory? do I need to care? etc (I'm aware this is all documented somewhere, and maybe I just need to make more of an effort). Whereas in something like Sublime Text there's an easily installable package manager that takes care of all these things for you. And if you really care to learn, you can drop into one of the packages and find easy-to-understand Python and JSON. Versus vimscript, weird config files and whatever else vim uses to configure things.
2. Multi-file support - Sublime has a Cmd + T fuzzy filename finder right out of the box. With vim (for a beginner) your choices are either: a) open multiple terminal windows with a single file in each, Cmd + Tab endlessly or b) open multiple files in the same editor and drop out of insert mode every time you want to switch files (way more keystrokes than Cmd + T or Ctrl + Tab; maybe there's a toggle file shortcut in Vim also). I'm aware that there exist plugins for fuzzy-file searching in vim also, but because of 1 I don't know how to find or install them.
3. Buffers and marks - I'm vaguely aware they exist. I'm not sure what they do and why they're important. Again, this one is probably on me rather than the tool itself.
I have been using pathogen since I started using vim, I can recommend it. (copy paste directions to install: https://github.com/tpope/vim-pathogen) And this is where you can find vim plug-ins: http://vimawesome.com/
After installing pathogen, to install a plug-in:
cd ~/.vim/bundle
git clone <url>
and you are done in most cases, some require adding a few lines on ~/.vimrc.
#2
There are multiple ways to work with multiple files. There are tabs in vim, split screens, files in buffer etc, these are all without plug-ins.
Thanks for the recommendation. The trouble (and again, maybe this is down to my lack of research) is that other commenters will recommend Vundle with links to similar resources (and I've tried both Vundle and Pathogen, sometimes one after another, ruining my ~/.vim dir :P). I can find all of these recommendations myself but (maybe I'm wrong here) there's no clear winner in the vim ecosystem. There's no single de-facto manager that's used by 90% of all vimmers. Hell, I know people who I think maintain their vim plugins and config and scripts using only git, so maybe a package manager isn't even that much of a priority for many users.
> There are tabs in vim, split screens, files in buffer etc, these are all without plug-ins.
Agreed, but cursory research tells me that you have to type multiple characters to switch between files. For example, the documentation page on buffers: http://vim.wikia.com/wiki/Vim_buffer_FAQ lists about 20 different buffer navigations (bNext, bnext, bprevious etc (and why there's no bPrevious is a big fat ¯\_(ツ)_/¯ )) but not a single command for toggling between two open files, a pretty common use case. Whereas text editors like Sublime leverage the already-known (from using browsers) Ctrl + T shortcut and provide you this really necessary action in fewer keystrokes (1 vs Esc (or your Esc shortcut key) + :bNext = 7 assuming there's no shortcut for "Next" though there probably is).
> There are multiple ways to work with multiple files.
And maybe that's the problem. There are multiple ways to do everything (multiple files, plugin management etc) rather than one "best" or "recommended" way that works for most users. This is understandable for a hacker's tool; options and flags rather than intelligent defaults. But it leaves newcomers somewhat adrift. I'm not criticizing the tool itself; Bram Molenaar and co. are doing an amazing job and we should all be grateful for such a high-quality tool that's freely available on practically every nix. Something like a canonical beginner's vim config that's aggressively maintained and everyone knows about would be nice though.
EDIT: How do you type a "*"?
EDIT: Looks like switching buffers (which I think is the same as toggling between files) is :b#, which is still 4 characters vs 1. http://vim.wikia.com/wiki/VimTip686#Switching_to_the_previou...
Aren't these all reasons to not bother learning vim?
Now thanks to the GNU Tools packaged with Git, you get Vim and OpenSSH as lovely extras. It's really nice to be able to switch back and forth between editing on Linux via SSH in Vim and then back in Windows.
If you're searching around and moving files via the DOS prompt, getting your daily Docker/Vagrant fix it becomes much more natural just to open Vim edit the file and close it.
Plus you can add the solarized colours to the DOS prompt and you get lovely syntax highlighting too.
Cygwin vs MinGW is a whole other argument, of course.
It's got nothing to do with Git - just that Git bundles the most up to date versions of GNU tools compiled for Windows. There were pre-cursors to Git, but Git packages them all nicely.
Just for sentimental reasons I love using DOS, same as any Linux user loves their shell. So having the tools natively in DOS is a much nicer experience.
Is there a study, or you just feel like it?
Being conservative, let’s say it makes you 5% more productive.
It's subjective. I'd like to see a before and after study, but empirically measuring code productivity is -- a hard problem.Still I think it could be measured.
IntelliJ is a great tool, too.
Other bonus for vi is that you are now capable of editing files on any unix server in the world.
vim is timeless.