What's new in Vim 8

5 Gtk 3 Support

This might not sound like the biggest deal, given that many of us use Vim purely in a terminal window, but for those who prefer an editor that fits in nicely with Gnome or Xfce, this is a welcome change. It's still possible to build Vim with a Gtk 2 interface, and Bram states that the differences between the UIs should be "hardly noticeable." In any case, it's good to see the Vim codebase being updated in terms of the front end as well.

Those are five of the most significant changes in Vim 8, but there's a lot more to discover as well, including partials, lambdas, and closures; a new testing framework for developers; extra options; and even new insert modes. Check out the resources [8] for the full list, including pointers to Help resources that you can use in Vim to explore the new features in greater detail. Your fresh new Vim 8.0 installation should be in /usr/local, so enjoy!

New to Vim? Get Started Here

If you've never used Vim before, or you dipped your toes into its waters but ran away scared (which is fair enough given how bare it looks), here's a quick guide to help you on your way. Vim has a very steep learning curve, and users still discover new tricks after decades of working with it, but once you have the basics sorted out, you can gradually discover its true power.

The first thing to do is create a simple Vim configuration file. Bare-bones Vim looks pretty intimidating, so put the following text into .vimrc in your home directory:

set number ruler laststatus=2 hlsearch ignorecase title wildmenu
syntax on

Now open that file in Vim (e.g., vim .vimrc in a terminal window), and you'll see a more attractive setup than vanilla Vim, with a ruler along the bottom showing the file name, current line, and current column, along with line numbers down the left and syntax highlighting for the configuration file.

Next, start exploring some of the movement keys. Press H, J, K, and L and see what they do – they move the cursor around, and may seem redundant when most keyboards have arrow keys. By using HJKL, however, you can navigate without having to move your fingers away from the center of your keyboard. Also try pressing W to move forward a word and B to move back. That's a lot faster, isn't it?

Try opening a bigger file in Vim, and then use Shift+H-M-L to move around inside the screen – the top, middle, and bottom, respectively. This is also much faster than pressing keys repeatedly or holding them down for a while. Press lowercase G twice (gg) to go right to the top of a file, and Shift+G to jump to the bottom. Another very useful way to navigate is using curly braces – { and } – which jump between paragraphs. Very useful when editing lots of text!

Vim works in two modes – command and insert – which takes some getting used to. As you're moving around, you're in command mode, but press I to insert text (you'll see "INSERT" at the bottom). When you're done editing text, press Esc to quit back to command mode. There are other keys for inserting text, such as Shift+A to append to the end of the line and Shift+O to open a new line beneath the current one. Always remember to hit Esc after editing, so you are in command mode by default, and enter :w to save a file and :q to quit (:q! to quit without saving).

Vim Is a Language

To really grok Vim, you need to think of it as a language, with commands being issued like verbs and objects following. For instance, take the following piece of text:


Move the cursor into the "baz" part, and then press the following keys exactly as written:


When you're finished, press Esc. What this means to Vim is: Change the text inside the brackets to hello. Do you see how it's like a verb? And even better, you can repeat these "sentences" by pressing the full stop (.) key. Go down to the next "baz" and press full stop (period), and it performs the whole operation again.

Now, we've only done a very simple editing operation here, but you can already see what's possible if you string together much more complicated text manipulation commands. Once you're familiar with Vim, editing jobs that used to take hours (or required fiddling with scripts or horrible-looking regular expressions) end up taking only seconds. You stop thinking of Vim as a text editor, but rather a powerful command-driven machine for manipulating text.

Those are just the basics – to see what else Vim is capable of, check out the Linux Voice video [10] we made that goes further with the editor's very powerful macro system (Figure 4).

Figure 4: To demonstrate why Vim is more than a mere text editor, we made a video [10] – take a look.

How to Install Vim 8

You may now be itching to try all these new features and get the shiny new version. Unless you're running a rolling release distro such as Arch, however, you may have to wait a while before Vim 8 packages are available in your repositories (and you may have to upgrade to a new release of your distro). Fear not, though, because it's also not difficult to build Vim from source code. This requires a bit of work at the command line, but if you like (or want to learn) Vim, chances are you're not afraid of the Bash prompt anyway.

First, grab vim-8.0.tar.bz2 from your nearest mirror [9], and in a terminal window, cd into the directory where you downloaded it, and extract it:

tar xfv vim-8.0.tar.bz2

This will create a new directory called vim80, so cd into that. Now you can run the configuration and code-building process with one command:


During the configuration stage early on, you'll be alerted to any missing dependencies – the main one you need is the development headers for Ncurses, so install that if you don't have it already (e.g., sudo apt-get install libncurses-dev). Once you've dealt with your dependencies, run make again, and compilation will begin.

Next, when the source is built and you're returned to the prompt, run this command as root:

make install

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95