Javatpoint Logo
Javatpoint Logo

How to Install VIM editor on Ubuntu?

Introduction

Vim is a text editor and improved version of Vi editor. It is designed to use as CLI (Command Line Interface) and GUI (Graphical User Interface) application.

It is designed and developed by Bram Moolenaar and first released on November, 1991. VIM is an open-source and free, screen-based text editor. The cross-platform expansion has made it present for several other systems since its publication for the Amiga. It was voted the most famous editor by the readers of Linux Journal in 2018; the developer survey, i.e., Stack Overflow, found it to be the 3rd most famous text editor in 2015 and the 5th most famous development environment in 2019.

In this tutorial, we will install VIM editor on the Ubuntu operating system. To install, make sure we have updated version of Ubuntu and functioning terminal.

Prerequisites

  • Ubuntu
  • Terminal

Brief History of VIM

The forerunner of VIM, Stevie, was made by Tim Thompson in 1987 for the Atari ST and further improved by G.R. Walter and Tony Andrews. Bram Moolenaar started operating on VIM, basing his implementation on Stevie for the Amiga system in 1988, along with the initial public release in 1991.

The title "VIM" was short for "Vi IMitation" during its initial release, but it was modified to "Vi IMproved" in 1993.

License of VIM

VIM is published upon the Vim license. It contains a few charityware clauses that inspire users who like the application to consider contributing to children. The Vim license is suitable with the GNU General Public License by a unique clause permitting the distribution of changed copies upon the GNU GPL 2.0 or later versions.

Interface of VIM

The interface of VIM isn't based on the icons or menus but on the commands provided inside the text user interface like VI; gVim, its GUI mode, includes toolbars and menus for generally used commands; however, the complete functionality is still represented by its commands line mode. Vi tends to permit a typist to place their fingers on the home row, which could be a benefit for a touch typist.

The VIM editor contains a built-in tutorial for newcomers known as vimtutor, which is basically installed with Vim. However, it is a different executable and could be executed using a shell command. The User Manual of Vim details the features of Vim and can be found online or executed from inside Vim.

Also, Vim includes a built-in help feature, which permits users to ask and navigate with features and commands.

Registers

Vim provides several unique memory entries known as registers (don't confuse them with processor or hardware registers). When copying, pasting, deleting, or cutting text, the user can select to save the manipulated text within a register. Thirty-six general-purpose registers are available that are related to numbers and letters and a variety of unique ones that either include unique values (last command, current filename, etc.) or serve a unique objective.

Modes

Vim supports two or more editing modes like vi. Type characters are specified either as command sequences or are entered as text, relying on the mode. 12 editing modes, six variants, and six common modes are available in Vim:

  • Normal mode: This mode is utilized for editor commands. Generally, it is the default mode, and hitting the ESC button returns the current editor to this mode by default.
  • Insert mode: This mode is utilized for typing text in a manner the same as the latest editors. In buffers, opened text can be changed with the text inserted from the keyboard in this mode.
  • Visual mode: This mode is used to choose text areas. Commands can be executed on the chosen area- filtering, editing, moving by external or built-in commands, etc.
    • Visual blockwise: It is a visual mode subtype that chooses a rectangular text block around one or multiple lines.
    • Visual linewise: It is another subtype that chooses one or multiple entire lines.
  • Select mode: This mode is the same as the visual mode, but the commands aren't interpreted; rather, highlighted text is substituted directly by input through the keyboard, which is the same as the selection mode utilized in editors on the platforms of Microsoft Windows.
  • Cmdline or Command-line mode: It offers one-line input at the base of the Vim window. Commands and a few other keys for particular actions (such as the filter command and pattern search) trigger this mode. The Vim editor returns to the older mode on the command's completion.
  • Ex mode: This mode accepts a command sequence.

Customization of VIM

Vim is highly extensible and customizable, making it an interesting tool for customers who demand a bigger amount of flexibility and control over the text editing platform. Text input is provided by a range of features developed to enhance keyboard efficiency. Customers can run hard commands using "key mapping", which could be extended and customized. The "recording" aspect permits the establishment of macros to activate keystroke sequences and call user-defined or internal mappings and functions.

Abbreviations, the same as key mappings or macros, provide the expansion of short text strings into longer ones and could also be used for correcting mistakes. Also, Vim facilitates an "easy" mode for customers looking for an easier solution to text editing.

Several plugins are available that enhance and include new functionality in Vim. Usually, these plugins are written in the internal scripting language Vim, vimscript (also called VimL), but can also be specified in other languages.

Many projects grouped together complex customizations and scripts and focused on turning Vim into a resource for a particular task or including a bigger flavor to its nature. Some examples are VimOutliner, which facilitates a comfortable outliner for Unix-like system users, and Cream, which enables Vim to act like a click-and-type editor.

Improvements and features of Vim

Vim includes a compatibility mode with vi, but when this mode isn't used, Vim contains several improvements over vi. But Vim isn't entirely suitable with vi as specified in POSIX and the Single Unix Specification alike in compatibility mode. The developers of Vim said that it's very much suitable with Vi.

  • A few enhancements of Vim contain completion functions, merging and comparison the file (called vimdiff), enhanced regular expressions, a comprehensive developed help system, scripting languages including plugin support, a graphical user interface (known as gvim), mouse interaction (without and with the GUI), limited development environment-like aspects, folding, spell checking, editing of archived and compressed files in tar, zip, bzip2, and gzip files and formats over network protocols, like HTTP, FTP, and SSH, tabbed and split windows, session state preservation, support for Unicode and multi-language, cursor and search position histories, syntax highlighting, trans-session command, visual mode, branching and multi-level redo/undo history which can carry on around editing sessions.
  • Vim stores the changes of the user in a swap file using the ".swp" extension while running.
  • This file could be utilized to restore after a failure. Vim will alert the users if they attempt to open any file and swap it with already existing ones, and Vim will utilize a swap file using the ".swo" extension if the user continues.
  • The functionality can be deactivated.

Vim script

It is also known as VimL or Vimscript. Vim script is a scripting language integrated into Vim. Early Vim versions added commands for function definitions and control flow, which is the ex-based editor language of the actual vi editor. Since the 7 version, Vim script supports more developed data types, including dictionaries and lists, and an easier mode of object-oriented programming. Many built-in functions, including filter() and map(), permit a common functional programming form, and the Vim script has contained lambda since the 8.0 version. Mostly, Vim script is specified in the form of imperative programming.

Vim macros can include a normal-mode command sequence but can also request ex-functions or commands specified in Vim script for harder tasks. Most extensions (known as plugins or scripts) of the Vim functionality are specified in the Vim script, although plugins can also use other languages, such as Racket, Tcl, Ruby, Lua, Python, or Perl. These plugins can manually be installed, or they can be installed by a plugin manager, like Vim-Plug, Pathogen, or Vundle.

The files of the Vim script are saved as plain text, the same as other code, and .vim is usually the extension of the filename. One important exception to it is the config file of Vim, i.e., .vimrc.

Availability of Vim

While the vi editor was available on Unix OSes originally, Vim has been shipped to several operating systems, such as Atari MiNT, AmigaOS, DOS, BeOS, Windows initiating from Windows NT 3.1, MorphOS, OS/390, OS/2, OpenVMS, RISC OS, QNX, BSD, Classic Mac OS, and Linux. Vim is also ported with Apple macOS. Vim-independent ports are available for iOS and Android.

Vim fork

Neovim is a Vim fork that aims to develop the maintainability and extensibility of Vim. Several features of this fork are available, including support for built-in Language Server Protocol, asynchronous I/O support, and Lua scripting support with the luaJIT language interpreter. It is an open-source software project, and its source code is present on GitHub.

After a Vim patch aiding multi-threading was dismissed, the Neovim project began in 2014. In March 2014, it had well fundraising, supporting a single full-time developer at least. Many frontends are supporting development that uses the capabilities of Neovim.

Neovim achieved built-in Language Server Protocol support and complete support for Lua, such as the capability of writing the primary configuration file in the Lua language rather than VimL with the 0.5 version of Neovim on 2 July 2021.

VIM Installation

Installing VIM editor is pretty easy, it just require a single command to install. The following command is used to install VIM editor.

Software Vi Editor 1

Type 'Y' and press enter, it will start installation of required packages and application.

After that, we can run vim either from the terminal or application manager.

We can find it in system by typing VIM, as we did below.

Software Vi Editor 2

Click on the icon and it will open a terminal for VIM editor. It looks something like the below.

Software Vi Editor 3

Well, we have successfully installed VIM editor on our system. Now, we can use it to code in any programming language.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA