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:
foobar(baz);
Move the cursor into the "baz" part, and then press the following keys exactly as written:
ci(hello
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).
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:
make
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
Infos
- Vim: http://www.vim.org/
- Vim downloads: http://www.vim.org/download.php#unix
- Vim-Airline: https://github.com/vim-airline/vim-airline
- Solarized: https://github.com/altercation/vim-colors-solarized
- Surround.vim: https://github.com/tpope/vim-surround
- NERD tree: https://github.com/scrooloose/nerdtree
- Fugitive.vim: https://github.com/tpope/vim-fugitive
- Resources: https://github.com/vim/vim/blob/master/runtime/doc/version8.txt
- Download: http://www.mirrorservice.org/pub/vim/unix/
- Video: https://www.youtube.com/watch?v=rfl9KQb_HVk
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome OS Adopting systemd-sysupdate
Gnome OS is about to undergo a major under-the-hood change that promises enhanced security.
-
Endless OS 6 has Arrived
After more than a year since the last update, the latest release of Endless OS is now available for general usage.
-
Fedora Asahi 40 Remix Available for Macs with Apple Silicon
If you've been anticipating KDE's Plasma 6 for your Apple Silicon-powered Mac, then you're in luck.
-
Red Hat Adds New Deployment Option for Enterprise Linux Platforms
Red Hat has re-imagined enterprise Linux for an AI future with Image Mode.
-
OSJH and LPI Release 2024 Open Source Pros Job Survey Results
See what open source professionals look for in a new role.
-
Proton 9.0-1 Released to Improve Gaming with Steam
The latest release of Proton 9 adds several improvements and fixes an issue that has been problematic for Linux users.
-
So Long Neofetch and Thanks for the Info
Today is a day that every Linux user who enjoys bragging about their system(s) will mourn, as Neofetch has come to an end.
-
Ubuntu 24.04 Comes with a “Flaw"
If you're thinking you might want to upgrade from your current Ubuntu release to the latest, there's something you might want to consider before doing so.
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.