What are the benefits of learning Vim?

VimEditor

Vim Problem Overview


As a programmer I spend a lot of hours at the keyboard and I've been doing it for the last 12 years, more or less. If there's something I've never gotten used to during all this time, it's these annoying and almost unconscious constant micro-interruptions I experience while coding, due to some of the most common code editing tasks. Things like a simple copy & paste from a different line (or even the same line), or moving 1 or 2 lines up or down from the current position require too much typing or involve the use of the arrow keys ...and it gets worse when I want to move further - I end up using the mouse. Now imagine this same scenario but on a laptop.

I've always considered learning VIM but the amount of time needed to master it has always made me want to step back.

I'd like to hear from people who have learnt it and if it ends up being one of those things you cannot live without.

At work, I use VS2008, C# and R#, which together make editing code a lot faster and easier than ever, but even so I think I could enjoy not having to use the mouse at all.

And not even the arrow keys.

Vim Solutions


Solution 1 - Vim

I've been using vi and vim also for some 20 years, and I'm still learning new things.

David Rayner's Best of Vim Tips site is an excellent list, though it's probably more useful once you have some familiarity with vim.

I also want to mention the ViEmu site which has some great info on vi/vim tips and especially the article Why, oh WHY, do those nutheads use vi? (archived version)

Solution 2 - Vim

Could I live without it? Easily.

Is it useful? Yes.

Reasons for Learning

  • vi is guaranteed to exist on all Unix systems and exists on most Linux ones as well. That kind of broad coverage makes learning it worth it.

  • It's much quicker to use vi for a sudo edit:

    $ sudo vi

  • Also, GMail uses vi-ish commands for selecting & moving emails around!

You don't have to be a master.

Just learn The basics:

  • How to switch from command mode to insert mode i
  • How to switch from insert mode to command mode Esc
  • How to navigate up a line in command mode k
  • How to navigate down a line in command mode j
  • How to navigate left a character in command mode h
  • How to navigate right a character l
  • How to save a file :wEnter (write)
  • How to exit without saving (in command mode) :q!Enter
  • How to Undo u
  • How to Redo Ctrl+r
  • You can combine writing and quitting (in command mode): :wqEnter

From there the rest will just make you faster.

Solution 3 - Vim

Running through vimtutor only took me 30 minutes, which was enough to get familiar with vim. It was worth every second of it.

Solution 4 - Vim

If you're a programmer who edits a lot of text, then it's important to learn an A Serious Text Editor. Which Serious Text Editor you learn is not terribly important and is largely dependent on the types of environments you expect to be editing in.

The reason is that these editors are highly optimized to perform the kinds of tasks that you will be doing a lot. For example, consider adding the same bit of text to the end of every line. This is trivial in A Serious Text Editor, but ridiculously cumbersome otherwise.

Usually vim's killer features are considered: A) that it's available on pretty much every Unix you'll ever encounter and B) your fingers very rarely have to leave the home row, which means you'll be able to edit text very, very quickly. It's also usually very fast and lightweight even when editing huge files.

There are plenty of alternatives, however. Emacs is the most common example, of course, and it's much more than just an advanced text editor if you really dig into it. I'm personally a very happy TextMate user now after years of using vim/gvim.

The trick to switching to any of these is to force yourself to use them the way they were intended. For example, in vim, if you're manually performing every step in a multi-step process or if you're using the arrow keys or the mouse then there's probably a better way to do it. Stop what you're doing and look it up.

If you do nothing else, learn the basic navigation controls for both vim and Emacs since they pop up all over the place. For example, you can use Emacs-style controls in any text input field in Mac OS, in most Unix shells, in Eclipse, etc. You can use vim-style controls in the less(1) command, on Slashdot, on gmail, etc.

Have fun!

Solution 5 - Vim

It's definitely worth the effort.

There's one obvious reason that anyone who uses Vi(m) will tell you, and two others that people never seem to mention.

Here's the obvious one:

  1. vi is at once ubiquitous and incredibly powerful, and by learning it once, you gain the ability to exercise that power on pretty much any computer that has a keyboard.

And these are the lesser known reasons to learn Vim:

  1. It's not half as much effort as you think it's going to be. Run through the Vim tutor once (vimtutor at a shell, or in Windows run it from the Vim folder in the Start Menu), and you'll already be well on your way to competence, and it's all downhill from there. I was up to the level where I could use Vim at work without taking any noticeable productivity hit within less than a week's worth of lunchtimes.

  2. It's fun! Editing text is like a game to me now. I actively enjoy it--which is pretty ridiculous, when you think about it.

There's also two good reasons not to learn Vim:

  1. It's addictive, and you'll find yourself wishing you could use Vim commands in all your computing, and cursing whenever you can't. Fortunately, at least for some situations, there's ways to get around this.

  2. Again, it's addictive, and although you won't lose any productivity from actually using Vim, you will waste hours searching for good tips to make your Vim experience even better, and reading the Vim tag on Stack Overflow.

Solution 6 - Vim

It's definitely worth learning either vim or emacs. It's also worth learning to touch-type. In both cases the reasons are the same: your thinking is no longer interrupted by the mechanical process of getting your code onto the screen.

As to how to start, just dive in and start using vim for everything.

P.S. The emacs-vs-vi debate is endless. I've been using emacs for 26 years. If I started again today I'd learn vim because (a) it's gotten better and (b) there are many fewer modifier keys (Ctl-Alt-V, anyone) and vim users seem to get much less typing injury.

Solution 7 - Vim

You can get good functionality out of vim by learning the meanings of only 16 keys: ijkdbw9:q!%s/nNEsc. You can do the bare bones with just i:wqEsc.

The first two keys you need to know are: Esc takes you to command mode (the mode you start in), and i takes you to insert mode (normal typing).


To save you need to

  1. get out of typing mode (Esc)
  2. type a colon :
  3. type lowercase w then Enter

To save-and-quit you need to

  1. get out of typing mode (Esc)
  2. type a colon :
  3. type lowercase wq then Enter

To not-save-and-force-quit you need to

  1. get out of typing mode (Esc)
  2. type a colon :
  3. type lowercase q! then Enter

To learn more you can run vimtutor at the command line. It's a medium-length, well-structured lesson.

Beyond i and Esc: you can replicate or surpass some MS Word functionality with only jkwbd3:%s/nN.

  1. b takes you back a word (Ctrl+)
  2. w takes you forward a word (Ctrl+)
  3. 9w takes you forward nine words
  4. db deletes the preceding word (Ctrl+Backspace)
  5. d3b deletes three preceding words
  6. 9j moves down 9 lines
  7. / ornithopter Enter takes you to the next instance of the word "ornithopter", then n and N to the next and previous occurrence of "ornithopter" respectively.
  8. :%s/confounded/dangfangled/ Enter substitutes every "confounded" with "dangfangled" (like find and replace all in MS Word)

Any of those should be run in "command" mode (Esc), not insert mode (i).

Solution 8 - Vim

I recently switched to VIM, and I think it's worth it. If you need to "just get something done", you can always stay in insert mode, where vim is (mostly) like a normal text editor.

I've noticed that things that didn't use to bother me, like reaching for the arrow keys, now feel wrong and too much effort. It's definitely decreased my hand motion and usage of the mouse, which is good for both ergonomics and productivity

Solution 9 - Vim

It depends what you want to do with VIM. It doesn't make sense to learn it only because many people cannot live without it.

When I was working a lot on UNIX environments, I couldn't live without it. Even when VIM was not installed on a UNIX machine, I could at least use vi. You could always count on it -- even if the machine is not yours (that from the customer).

Now I program in C# and mostly work on windows environment. I have installed VIM on my PC ... and I don't need it.

Evaluate if you really need VIM and if it supports you in your "flow of work". Try it out. Play with it. If you think you need it, stick to it ... the learning curve is very steep.

Solution 10 - Vim

I learnt vi because I had to.

My crazy teacher forced us to learn to program in C using a terminal to an AIX system.

It was a real pain, but worth it.

Today, I only use vi for quick edits or small programs.

When I have to go for a project, I rather use and IDE. In my case IntelliJ idea is very good at the task, because I can code for hours without grabbing the mouse.

I don't know how much shortcuts does VS2008 has, but if they are as discoverable as Eclipse, I think you are in trouble go for vi.

If you DON'T edit code outside the IDE and your IDE has good shortcuts, you better learn those, and then, go and learn vi anyway.

:)

Solution 11 - Vim

I've used vi/vim for 25+ years. If you already know some command-line editor, then maybe you don't need to learn vi/vim. But if you don't know any other command-line editors very well, it's worth learning it. It's pretty easy to be productive in vi/vim with little effort.

Solution 12 - Vim

I use VIM pretty much exclusively now.

I used to use Vim for editing and VS Editor for debugging. This probably seems a bit crazy, but I found the Vi paradigm (macros, home key based editing etc) such a boost to my productivity, that editing in VS was paintful.

Thanks to http://www.viemu.com/">Viemu</a>;, I don't even have to do the switching any more. It is not the perfect solution yet (code completion is sometimes not as elegant as in native vim and the macro recording isn't perfect), but it is much better than switching back and forth constantly.

The learning curve for Vim is probably exaggerated. I think once you get into it, it is pretty intuitive.

Solution 13 - Vim

My job forced me to pick up vim and it has quickly become second nature. Now my complaints are about IDE's that do not have vim emulation or plugins. I do notice that the esc key has become my enemy outside of vim.

I did find several emulators for vi within Visual Studio:

http://code.google.com/p/vim-visual-studio/

Solution 14 - Vim

Firstly good vi(m) knowledge will save you the time you have to hustle to do emergency editing of config files on a server under seige. It can hold up on a laggy ssh connection.

Admin stuff aside vim's input method will be your best defence against carpal tunnel if you use it effectively with an ergonomic keyboard.

The best way to see the point of vim is to start a casual project at home, unplug your mouse and tape over your arrow keys.

And read the help

Solution 15 - Vim

Two advantages of vi/vim:

  • it is very light-weight

  • it is installed on almost every *NIX system

Solution 16 - Vim

I am maintaining a very big linux project on the remote computer. There is no choise to use Eclipse or similar GTK based IDE. I've been working there for 3 years. And I set my vim just for this project. And still tweaking.

Now I can do any thing from the Vim: source control, sql, debug, compile, browsing - really fast browsing over 1Gb source code.

Visual Studio or Eclipse couldn't handle all of this. And If I had a choice I would'n change Vim to other editor or IDE.

Solution 17 - Vim

I learned Vim. It wasn't too much effort. Now I absolutely love ci" ci( cw V:s/from/to/g

Solution 18 - Vim

I'd say vim is definitely worth learning. I picked it up last summer, and it is now my editor of choice for just about everything (java is a stretch, but doable when I don't need extensive analysis support). As everyone has already affirmed, it is a wonderfully efficient tool.

For what it's worth, I only learned a fairly small subset of vim's features (which took a day or two) from a graphical tutorial, and a few odds and ends from here (long read), and the search and replace functionality, and I was hooked. I've learned things since then, but at my leisure. I'd say the learning curve flattens out at this point, but then, I was using it pretty heavily and was surrounded by others who were, too.

Solution 19 - Vim

I'm in the same situation as you, and as a beginner to Vim I originally found it a little daunting - the learning curve seems steep. From what I've learned in just a few hours I'm already feeling like I won't be able to live without it.

Here are a few links that I've found for useful Vim screencasts to show you what it's capable of.

A good bit of advice that Bram Moolenaar (benevolent dictator of Vim) gave in that last link is that it would be inefficient to try to learn every single command and function, just figure out what it is that you're doing that isn't working very well, look for a way to make it more efficient and then make it a habit.

Solution 20 - Vim

Yes, definately take the time to learn at least a bit of 'vi' and 'vim'. It travels very well.

You'll never be stuck when you are faced with a customer Unix/Linux/Mac system that you don't have install capabilities for. Even on Windows (if you do have install capabilities) 'Vim' is free and easy to install. (As opposed to investing your learning curve purely in something like UltraEdit, which although an excellent editor might not be available for you all the time...).

Learning vi can set you up for learning other tools like 'sed', and regex in general: stuff that is generally transferable.

Plus if you want to be a proper geek, you just simply need to know 'vi/m' or you'll look like a faker ;-)

Solution 21 - Vim

I think it's definitely worth the time and effort to learn vim. To me, it makes typing and navigating around text so efficient, it's hard to imagine going back to emacs or ctrl/shift/alt/meta key combos.

Don't get intimidated by all the fancy features of vim. Once you've used it enough, you'll figure out which commands you use the most, and you'll figure out which things you can forget about.

Solution 22 - Vim

The amazing ubiquity of Vim, and the even more amazing ubiquity of Vi-clones in general, on Unix systems alone is enough to make it worth learning.

Besides that, the whole Vi-style thinking is something that I really think has made me a bit more productive. For a person not used to modes such as the command mode and insert mode, it seems a bit excessive to have to enter a mode just to insert text. But, when one has been using Vim for a few months, and has learned quite a few tips and tricks, Vim seems to be an asset that seems to be worth it.

Of course, the Emacs crowd says the same thing regarding Emacs-style thinking, but I gave up on learning Emacs because Vim was simpler and did the job for me.

Solution 23 - Vim

I learned to like vi after watching someone who was very skilled with it navigate around to make edits at an insanely fast clip. You really can code quickly with it. Another reason I like it is that sometimes I find that mousing around in an IDE really hurts my hands after a while and vi provides a nice change. As others have mentioned it's also almost always available on unix systems and works well even over lousy connections.

One thing that I haven't seen mentioned is that knowing vi has the added benefit of "geek cred" in some circles. I can think of at least a few people who chuckle when they see a new programmer fire up nedit to make some changes to a file.

Solution 24 - Vim

Don't be scared off by the number of commands, I've not met anyone who used more than a couple dozen at most. I find it indispensable, because when I'm thinking about code I'm thinking about text, moving to thinking about mice just messes me up. The big tricks, I think, are to learn it a little at a time, and don't be hesitant to play around - the undo features is great for exploring its behaviors.

Also, if you get deeply into it, vim is scriptable. The possibilities are literally endless.

(Yes, all of this applies to emacs too...)

Solution 25 - Vim

I was happy at my textpad and ecplise world until i had to start working with servers running under linux. Remote scripting and set up of config files was needed!

It was hard at the begining but now i can easily set up and tune up my servers.

Solution 26 - Vim

You might want to learn vim because you might not be happy with the editors you're already using.

You might want to learn vim because many people say it is cool. Just look how many answers you've got to this question.

I will provide an additional reason for learning vim. It has a reputation for the quality and the completeness of its docs. So you will find most answers to your questions in its help system as soon as you will manage to stick the proper keywords in your help queries.

Solution 27 - Vim

To learn vi(m) fast one must first understand the whole design. Vim has a great set of cursor-movement commands, check a few (X is a character, # a digit):

j k enter arrows 0 $ w W b B ctrolD crtolU ctrolE ctrolY H M L fX FX tX TX , ; % gg G n N mX 'X ''

and many more it would be boring to enumerate. Many of these support a count before the command, like 4j to move 4 lines up.

Now, back to the design, you type a command like d for delete followed by a cursor movement and the command applies to the piece of text from the cursor position till the movement end. For example H moves to the top of the screen, dH deletes to the top of the screen and cH changes (replaces) to the top of the screen.

This design is quite powerful. It also reduces, or organizes, what you need to learn. Definitively the first step is to learn a few cursor movement commands. Say,8 or 10 at first. Then you are almost done.

Solution 28 - Vim

Learning something new is always worth the effort, IMHO. I suggest you print out a cheat sheet and force yourself to use it day-in and day-out.

Solution 29 - Vim

Vim is definitely worth learning to partly summarize what has been stated previously here are the main reasons:

  • Vi/Vim can be found on most unix systems.
  • Vim allows you to easily code without taking your hands off the keyboard.
  • If you plan you configure anything in a unix based system likelihood is you going to be editing a fair few config files, therefore you'll want to learn a terminal based editor, of which vim is one of the best (sorry emacs).
  • Vim compiles/has precompiled binaries for almost every OS out there. No need to post "I need a textmate alternative for [insert OS]", you'll have Vim instead!
  • There are a lot of good plugins out there to add alot of functionality, such as in-editor cvs diffs, although some of these require a fair amount of tinkering.

Also on a side note if you find you like the Vim key bindings, there are also IDEs which include vim bindings in their editors for simple commands, for example Komodo Edit.

For help on learning Vim, try typing 'vimtutor' into your terminal and follow the instructions. There is also a book which is particularly good Hacking Vim

Solution 30 - Vim

No. Learning vim is worth more than the effort.

Solution 31 - Vim

I too put off learning vi or vim for many years. Matter of fact, I use to make fun of the "vi guys" who always seemed to be doing finger aerobics. Then, as I moved away from Windows and over to Linux as my primary OS, I had to become more familiar with vim. It was a learning curve and it still is. After 9 years of using vim on a daily basis I still find myself learning new and faster ways of doing things. What I use to think of as "finger aerobics" actually turned out to be an extremely efficient way of being productive. I can now do a whole lot more code development in a whole lot less time and effort than I ever did prior to vim. And as I'm sure you know vim runs on about every platform out there so you always have it when you need it. Also, if you like GUI's they have GUI versions for most platforms. Personally, just like the mouse, I don't want to see a menu bar, scroll bars, etc. cluttering up my editing window(s).

If you decide to give vim a whirl I would highly recommend the O'Reilly "vi Editor Pocket Reference" book. It's cheap and it's great if you're just learning vi (vim). The full blown vim books are also good but the pocket reference gives you all the basics to be productive quickly.

Solution 32 - Vim

Yes: If you don't use and don't plan to use any IDE in future. And even if you use an IDE you will find yourself returning to it to do many things. In vim you van write scripts, do complex tasks like instead of individually editing 500 lines do it with a (slightly cryptic but easy to understand once you pick up) command. I initally found it difficult but later it has helped me lot. Even the best IDE's editor will lack the power of vim. Vim can work well with CVS, SVN, make, debuggers etc.

No: If you will stick to IDEs like Eclipse or Netbeans. Or if you find that editors like Kate are enough for you. Infact Kate or Notepad++ or jEdit have GUI and features you may miss in vim. e.g. Kate's symbol viewer or Notepad++'s huge menu bar.

Solution 33 - Vim

Personally,

I find many of these terminal text editors incapable at times. Would I invest time picking one up? Absolutely! I would continue to learning one along side a IDE. Of course in the end, it really comes down to preference.

Solution 34 - Vim

An investment in learning VIM (my preference) or EMACS will pay off.

I suggest visiting Derek Wyatt's site, running through the VIM Tutor, and checking out the Steve Oualine PDF book.

Vim helps me move around and edit quicker than other editors I've used. My work IDEs are quite limited in what they allow one to do and are typically devoted to a particular environment. There are tasks that still require me to revisit the IDE (such as debuggers which are a compiled part of the IDE).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTrapView Question on Stackoverflow
Solution 1 - VimGreg HewgillView Answer on Stackoverflow
Solution 2 - VimTrampas KirkView Answer on Stackoverflow
Solution 3 - VimСычView Answer on Stackoverflow
Solution 4 - VimRyan BrightView Answer on Stackoverflow
Solution 5 - VimRichView Answer on Stackoverflow
Solution 6 - VimNorman RamseyView Answer on Stackoverflow
Solution 7 - VimisomorphismesView Answer on Stackoverflow
Solution 8 - VimGabe MoothartView Answer on Stackoverflow
Solution 9 - VimTheo LenndorffView Answer on Stackoverflow
Solution 10 - VimOscarRyzView Answer on Stackoverflow
Solution 11 - VimCraig SView Answer on Stackoverflow
Solution 12 - VimRedBlueThingView Answer on Stackoverflow
Solution 13 - VimCourtlandView Answer on Stackoverflow
Solution 14 - VimmichaelView Answer on Stackoverflow
Solution 15 - VimPaulView Answer on Stackoverflow
Solution 16 - VimMykola GolubyevView Answer on Stackoverflow
Solution 17 - VimthomasrutterView Answer on Stackoverflow
Solution 18 - VimEllery NewcomerView Answer on Stackoverflow
Solution 19 - VimAndyView Answer on Stackoverflow
Solution 20 - VimmonojohnnyView Answer on Stackoverflow
Solution 21 - VimAndy WhiteView Answer on Stackoverflow
Solution 22 - VimJames MishraView Answer on Stackoverflow
Solution 23 - VimDana RobinsonView Answer on Stackoverflow
Solution 24 - VimKim ReeceView Answer on Stackoverflow
Solution 25 - VimCesarView Answer on Stackoverflow
Solution 26 - VimAnonymousView Answer on Stackoverflow
Solution 27 - VimJuan LanusView Answer on Stackoverflow
Solution 28 - VimswitchmodeView Answer on Stackoverflow
Solution 29 - VimJamieView Answer on Stackoverflow
Solution 30 - VimojblassView Answer on Stackoverflow
Solution 31 - Vimuser71918View Answer on Stackoverflow
Solution 32 - VimXolveView Answer on Stackoverflow
Solution 33 - VimRev316View Answer on Stackoverflow
Solution 34 - VimmodalView Answer on Stackoverflow