While developers can create highly innovative applications and software, the vast majority of their work consists of editing text files. These communicate instructions to the machines responsible for executing the code.
In this context, developers need to use tools that make it easier to enter code. These are known as text editors. The simpler and more efficient they are to use, the easier it is for designers and developers. This is precisely the aim of Vim, a highly configurable and customisable text editor. Find out everything you need to know about this programme.
What is Vim?
Vim is a highly configurable text editor available on all Unix systems, but it is also available on MS-Windows (7, 8, 10, 11), macOS, Haïku and VMS.
It is an enhanced version of UNIX/VI developed in 1991 by Bram Moolenaar. In fact, the term Vim comes from Vi IMproved. And even today, it continues to improve thanks to the addition of new, ever more powerful features.
The aim of all these features is to make it easier to create and modify any type of text. Although Vim is often referred to as “the developer’s editor”, it is not just used for programming software and applications. In fact, this tool can be used for all types of text editing (such as writing e-mails or editing configuration files).
Vim can also be used by data experts. It enables them to sort and correct databases containing thousands of heterogeneous lines.
Â
💡 Related articles:
Good to know: Vim is a modal editor. This means that it works differently depending on the mode you select. Depending on the operations you perform, you can switch from one mode to another. While this modal function increases the range of possibilities with Vim tenfold, it also makes the software more complex to use.
What are the different Vim modes?
As we saw earlier, Vim uses different modes to work. This is not necessarily the case with the vast majority of text editors, most of which operate in a single mode.
So what are Vim’s different modes and how do they work? Here’s an overview.
![](https://datascientest.com/wp-content/uploads/2023/05/vim-editeur-text-datascientest1.png)
Editing, inserting and replacing
Here, each character is inserted into the file below the cursor. When you switch to this insertion mode, you have no menu, no copy-paste, no file. Just a text field.
Good to know: this is not the default mode. If you want to work in insert mode, you need to type different character strings from command mode. For example: “a” allows you to move after the cursor, “i” under the cursor, etc.
Commande
This mode is used as soon as the Vim interface is launched. Logically, this is the mode most often used by developers. In fact, its operation is more like that of other text editors.
If there is only one command mode, you can use either Vim commands or Ex commands.
Here are some examples of Vim commands:
c = change text
cc = change the whole line
d = delete text
y = copy text, etc
Good to know: here, you don’t know what you’re typing. To get visual feedback, you need to type “:set showcmd”.
Conversely, Ex commands give you maximum transparency. Here are a few examples:
:e = edit a file
:w = save a file
:q = exit the window
:bprevious = display previously opened files.
Some commands can be found in both Vim and Ex.
Visual
This allows you to make selections throughout your text file (a bit like using the mouse). You can also use certain move commands to make selections.
For example, :
v25g: this moves you to the beginning of line 25
o: moves you from one end of the selection to the other.
Good to know: if you are in command mode, you can switch to visual mode by pressing the v key.
What are the advantages of Vim?
At first glance, the Vim text editor may seem a little austere. And yet it is one of the preferred tools of developers. There are several reasons for this:
- Its power: Vim users benefit from powerful search and replace functions
- Its features: for example, automatic completion, file comparison, advanced searches, command line history, online help, spell checking, block operations, scripting language, etc.
- Customisation: to make it easier to create and modify software and applications, Vim offers users a wide variety of extensions.
- Adaptability: Vim supports hundreds of programming languages and file formats. It also integrates with a wide range of tools.
- Continuous improvement: Vim is continually developed to offer users even more features to meet their needs.
If you’d like to find out more about the features and use of Vim, don’t hesitate to join our training courses at DataScientest.
Key facts:
- Vim is a highly customisable text editor.
It works in several modes to perform a variety of tasks. - The most common is command mode, which lets you open a file, save data, copy and paste text, and so on.
- To find out more about how Vim works, join DataScientest.