[This article is under construction!]
(and may be for a long time, since I'll be adding some new examples if I find them useful)

I've been using Vim for ages now, but every now and then I find another gem in it. I agree, you need to force yourself to use it at the very beginning, but after a month or two it becomes your second nature. And  a great incentive for you to learn it is that is existent and installed on nearly all UNIX systems. Whichever exotic operating system you encounter, Vim will probably be there!

Let's say this clear, Vim is not a text editor. MS Word or Open Office Writer is a text editor. Neither it is an IDE, although is has syntax colouring. GVim is rather a text processor. It helps you process files, text or binary. Text editor and text processor complement each other, they are used for different things.

There are many very good web sites describing Vim features, like for example this, but I just want to share a few, that are useful for me from time to time.

  1. To delete each line containing or not containing pattern use the d command:
    :g/pattern/d
    :g!/pattern/d
  2. Reverse line order of a file:
    ::g/^/m0
    It is actually a clever way of doing this. According to :help multi-repeat, :g and its cousin :v work in a two-pass manner. The first pass of :g marks every line matching {pattern}, while the second pass (apparently performed starting at the file's beginning and proceeding to the end) performs the [cmd]. The above use of :g takes advantage of the order the lines are processed in (which is probably okay, though probably not technically guaranteed). It works by first marking every line, then moving the first marked line to the top of the file, then moving the second to the top of the file (above the line moved previously), then the third marked line (again above the previously moved line), and so on until the last line in the file is moved to the top, effectively reversing the file.