Ask HN: Why programmers should use Vim?

In a lot of articles, video tutorials and books I see that programmers use VIM instead of a better editor like Sublime Text or something.

I'm a programmer. I build apps with NodeJs, JavaScript, CSS and Python and I feel really better when I use Sublime Text because it's visual, I can use the mouse cursor for moving between tabs or copy or paste codes, then WHY should I use VIM? I mean is there any secret behind VIM that I (and maybe many other programmers) don't know?

  • Tools are tools.

    So long as you're using a screw-driver, and not a hammer, for screws what tool you choose is up to you.

    But some screwdrivers are better than others. They are made from better materials, and have nicer grips, and better heads. The warranty is for the life of the user. They have little features that advanced users know appreciate[1].

    Please don't call one tool "better". Please use phrases like "I prefer this tool". So called 'religious wars' have consumed many megabytes of Internet bandwidth, and usually don't achieve much.

    It's a great question though - what are the benefits of tool X that I don't know about? It's a shame that this kind of question is banned from Stack Exchange which has a huge userbase of people who'd be able to give you great responses.

    [1] Some people don't seem to know that you place your index finger on the spinning end and use your middle finger and thumb to turn the driver. Also, form a loose fist, extend your index finger, insert the driver into the fist so the head of the driver rests by the tip of your finger. You can hold a screw as you move the driver to the hole the screw needs to be in.

  • > I mean is there any secret behind VIM that I (and maybe many other programmers) don't know?

    Yes. This article is probably a good overview of those secrets: http://www.terminally-incoherent.com/blog/2012/03/21/why-vim...

  • First, Sublime Text is not a "better" editor than Vim. You may find it "easier on the eyes", "easier to learn", "more comfortable", "more modern", "more intuitive" but as far as text editing goes, it doesn't hold a candle to Vim. And its text editing is a large part of the Vim's appeal for the programmers who use it.

    Second, programmers shouldn't learn Vim. Programmers should learn whatever makes them better programmers. If you think nothing beats your current tools/languages/practices there's no point even looking elsewhere. Just keep trucking.

    Third, Vim is just as "visual" as ST: you "can use the mouse cursor for moving between tabs or copy or paste codes" just as you would do in ST. The catch is that, for many programmers and most people who work with text, the mouse isn't a very good manipulation tool for words, lines or the arguments of a function. For those people, the keyboard is the best tool for the job and the mouse usually stays there, unused for hours. You can use your mouse in Vim to select text, paste, resize or focus windows, click on quickfix errors or click on a file name in netrw to edit it… but Vim offers much more than what can be done with the mouse or even with your usual Ctrl+Alt+Shift+x combos. Whether that's something valuable is entirely up to you.

    If you don't mind pressing thousands of Ctrl+arrows a day then Vim's wWbBeE$0^(){} won't appeal to you. And it doesn't matter. If you are comfortable with your setup, stick with it. No one will judge you negatively for that.

    I started to learn Vim because I was in the process of switching from Mac OS X to Linux and the last and most important part was the editor. I was very efficient with TextMate and, well… I just wanted a cross-platform alternative. I wasn't looking for something better than what I was used to but I wanted something that did just as much.

    It's only after a while that the evidence jumped at me that TextMate was in fact very limited and that Vim's design (its famed "language", text-objects, modes and so on) was an order of magnitude more empowering than TextMate's lush but too conventional features.

  • Well I suppose I could start with the fact that you called SublimeText a better editor - but I'm giving you the benefit of the doubt that when you said "or something" you meant emacs :)

    The thing is, people like to avoid using the mouse.

    It may feel more comfortable to use a mouse but avoiding it can increase your productivity. It may be perception but I don't think it is, from my personal experience.

    What VIM offers over SublimeText is superior text editing capabilities. SublimeText just looks great, so use a VIM mode for SublimeText if you think you are missing out on VIM.

    Another benefit to VIM is it is ubiquitous because some form of it is installed on every modern machine (that isn't windows). Also, as mentioned above most editors have a plugin that emulates vim/vi.

    Lastly, being able to effectively edit code over SSH like it is your native code editing environment is a pretty big bonus.

    Learning VIM pays off in many ways.

    -An emacs user

  • I use vim because I like it better than anything else. I'm not going to tell you that you need to use it. An editor's purpose is to make the process of turning thought into code as pleasurable as possible. There's not much more to it than that. If you like Sublime, then use it.

  • Well, programmers should use whatever they feel comfortable using. Sure Vim and Emacs have a much steeper learning curve and they are also much more productive and powerful once you master them, but it dosn't work for everyone.

    For starters, if you have your hands on your keyboard, moving them to reach the mouse takes time, so if you can do everyting without moving your hands, this is something that improves your workflow.

    Secondly, even moving your hands on the keyboard to reach for the arrow keys makes you loose time, so if you can do the same without moving them from the main row...

    On third place, with Vim, once you master navigation you moove pretty fast. You can move to the end/beginning of the next previous word, etc, and specify the number of times you want to do that just by prepending a number before the action. You can use regular expressions to search and replace (yes, I know, you can do that with other editors as well).

    And many more advanced, powerful features and shortcuts that you learn over time.

    You can just ssh to any linux/unix and edit a file really quickly. On some boxes it's the only editor available. This one alone is a really good reason to learn at least the basics of Vim.

    Then, it's a personal choice. I force me to use it and learn and improve, but because I want to master it, you might not have the same goals as me. And of course you can leverage what you already know about Vim without giving up the benefits of other tools. For instance, you can prefer to use an IDE instead of just a text editor for some programming languages, so you can just use Eclipse, IDEA... along with their Vim plugins.

    Of course you can configure Sublime Text to use Vim keybindings as well, so you can have best of both worlds.

    Overall, I guess it depends if you like commandline. I love commandline, so the ability to have something like tmux over ssh + vim is really powerful once you know how to use it.

    In the end, it's a matter of personal preference.

  • "...instead of a better editor like Sublime Text"

    Made me cringe.

  • "There are two editors that continue to reward learning. Your hands are going to fail. One of the editors is easier on your hands. QED: Vim."

    - @garybernhardt

  • I use Sublime Text 3. I code faster in ST than in vim.

  • They like that comand line look and feel.

  • emacs