Jump to content

Vim (text editor)

From Alfawiki
Vim
Company typeFree and open-source software
IndustrySoftware
Founded1991
FounderBram Moolenaar
Area served
Cross-platform
ProductsText editor software
Websitehttps://www.vim.org/

Vim (; vi improved) is a free and open-source screen-based text editor software. It serves as a sophisticated successor to Bill Joy's original vi. Bram Moolenaar initiated Vim by porting the Stevie editor to the Amiga, making it publicly accessible in 1991. Vim can be utilized through both a command-line interface and as an independent graphical program.

Initially developed for the Amiga platform, Vim has since evolved into a cross-platform tool compatible with a wide range of operating systems. Its popularity is evident: in 2018, it was recognized as the top editor by readers of Linux Journal; in 2015, it ranked third among text editors according to the Stack Overflow developer survey; and in 2019, it was placed fifth among development environments.

History

The foundation for Vim was laid by Stevie (ST Editor for VI Enthusiasts), created by Tim Thompson in 1987 for the Atari ST, with subsequent enhancements by Tony Andrews and G.R. (Fred) Walter. Stevie emerged as one of the earliest widely-used Vi clones without incorporating Vi’s original source code, which was derived from the Ed editor under AT&T licensing restrictions. By adopting Stevie’s codebase, Vim bypassed these licensing limitations.

Building upon Stevie's framework, Bram Moolenaar began Vim’s development on the Amiga in 1988, releasing the initial public version (Vim v1.14) in 1991. The acronym "Vim" originally meant "Vi IMitation," but was redefined as "Vi IMproved" by late 1993.

Release history

Date Version Updates and Enhancements
June 1987 N/A Tim Thompson launches Stevie (ST Editor for VI Enthusiasts), a basic vi clone for the Atari ST, sharing its source code on Usenet.
June 1988 N/A Tony Andrews enhances Stevie, ports it to Unix and OS/2, releasing version 3.10 via Usenet.
1988 1.0 Bram Moolenaar develops Vi IMitation for Amiga based on Stevie; not released publicly.
2 November 1991 1.14 First public release on the Amiga, distributed on Fred Fish disk #591.
1992 1.22 Unix port created but not released publicly; Vim begins to rival vi.
14 December 1993 2.0 Rebranded as Vi IMproved with this initial official release.
12 August 1994 3.0 Multi-window functionality introduced.
29 May 1996 4.0 Debut of a Graphical user interface.
19 February 1998 5.0 Syntax highlighting and foundational scripting features (user-defined functions and commands) added.
6 April 1998 5.1 Various bug fixes and enhancements implemented.
27 April 1998 5.2 Support for long lines, file browser, dialogs, popup menus, select mode, session management, user-defined functions/commands, and a Tcl interface introduced.
31 August 1998 5.3 Bug fixes applied.
25 July 1999 5.4 Basic file encryption capability and multiple improvements included.
19 September 1999 5.5 Further bug fixes and refinements made.
16 January 2000 5.6 New syntax files added alongside bug corrections.
24 June 2000 5.7 Additional syntax files and bug fixes released.
31 May 2001 5.8 Updated syntax files and resolved bugs.
26 September 2001 6.0 Folding, plugin support, and multi-language capabilities introduced.
24 March 2002 6.1 Bug fixes addressed.
1 June 2003 6.2 GTK2 and libgnome2 integration; Arabic language support; introduction of :try command; minor feature additions; bug resolutions.
7 June 2004 6.3 Bug fixes, translation updates, improved marks functionality.
15 October 2005 6.4 Bug corrections; updates to Perl, Python, Ruby support.
7 May 2006 7.0 Spell checking added; code completion introduced; tab pages enabled multiple viewports/window layouts; current line/column highlighting; undo branches implemented.
12 May 2007 7.1 Bug fixes; updated syntax and runtime files included.
9 August 2008 7.2 Floating point scripting support added; screen drawing code refactored; bug fixes; new syntax files included.
15 August 2010 7.3 Lua scripting support added; Python3 compatibility introduced; Blowfish encryption implemented; persistent undo/redo enabled.
10 August 2013 7.4 Faster regular expression engine incorporated.
12 September 2016 8.0 Asynchronous I/O support added along with jobs and lambda functions.
18 May 2018 8.1 Terminal window capabilities and terminal gdb plugin introduced.
13 December 2019 8.2 Popup windows and text properties features added.
28 June 2022 9.0 Vim9 scripting language launched for improved scripting power.
2 January 2024 9.1 Classes and objects support for Vim9 script added; smooth scrolling and virtual text features introduced.


License

Vim is distributed under the Vim license, which incorporates charityware provisions encouraging donations to support children in Uganda. Through a unique clause, this license permits compatibility with the GNU General Public License, allowing modified versions to be shared under the terms of the GNU GPL version 2.0 or later.

Interface

Vim’s user interface, much like that of vi, is primarily command-driven within a text user interface environment, foregoing traditional menus and icons. Its graphical counterpart, gVim, introduces menus and toolbars for frequently used commands, yet the complete feature set remains accessible via the command line. This approach benefits touch typists by allowing them to maintain their hands on the home row without interruption.

For newcomers, Vim includes a built-in tutorial named vimtutor, typically installed alongside the editor and launched separately through a shell command. The extensive Users' Manual thoroughly explains Vim’s capabilities and can be accessed both inside the editor and online.

Additionally, Vim features an integrated help system accessible through the :help command, facilitating navigation through its commands and functionalities.

Registers

Vim utilizes special storage locations called registers to hold text during operations such as cutting, copying, and pasting. There are 36 general-purpose registers identified by [a-z0-9], along with several special registers that store information like the current filename or most recent command, thereby streamlining text editing processes.

Modes

Similar to vi, Vim operates with multiple editing modes where keystrokes are interpreted differently depending on the active mode. It supports 14 modes in total—7 fundamental ones and 7 variants:[1]

  • Normal mode – the default state for executing editor commands; pressing returns here.
  • Insert mode – allows text entry and modification akin to contemporary editors.[2]
  • Visual mode – enables selection of text regions for operations such as moving or editing.
    • Visual linewise selects entire lines.
    • Visual blockwise selects rectangular text segments.
  • Select mode – similar to visual mode but replaces selected text immediately when typing, comparable to behavior in Windows editors.
  • Command-line (Cmdline) mode – provides a single-line input at the bottom for commands beginning with , searches, and filters; it reverts to the previous mode after execution.[2]
  • Ex mode – accepts sequences of commands.
  • Terminal-Job mode – manages interaction with jobs running in terminal windows.

Customization

Vim’s broad customization options and extensibility attract users desiring granular control and adaptability in their text editing workflow.[3] Key features aimed at enhancing keyboard productivity include configurable "key bindings" that enable complex command sequences and a "recording" feature for creating macros that automate keystrokes and invoke built-in or custom functions. Abbreviations allow short strings to expand into longer phrases to improve efficiency or correct errors. An "easy" mode is available to simplify Vim’s interface for less experienced users.[4]

A wide variety of plugins extend Vim’s core capabilities, mostly authored in its native scripting language vimscript (VimL), although other programming languages are supported.[5] Some bundled projects provide specialized customizations for targeted tasks or significant interface modifications—for example, Cream introduces point-and-click functionality, while VimOutliner enhances outlining features on Unix-like platforms.

Features and enhancements compared to vi

While Vim includes a compatibility mode for vi, it offers a wide array of improvements beyond this mode. Although designed to be "largely compatible with Vi," Vim does not fully adhere to the Single Unix Specification or POSIX standards—for example, it omits vi's open mode, providing only visual mode instead.

Notable advancements encompass sophisticated autocomplete capabilities, tools for file comparison and merging (vimdiff), a built-in help system, enhanced regular expressions, and support for multiple scripting languages such as Perl, Python, Ruby, and Tcl. Additionally, Vim accommodates plugins, features a graphical user interface (gvim), incorporates limited IDE-like functionality, enables mouse interaction both with and without the GUI, supports code folding, and allows editing of compressed or archived files (including gzip, bzip2, zip, and tar formats). Network-based editing over SSH, FTP, and HTTP protocols is possible as well. Other features include session state saving, spell checking, split and tabbed windows, comprehensive Unicode and multilingual support, syntax highlighting, cross-session command/search/cursor history tracking, and a multi-level undo/redo system that persists between sessions.

For crash recovery purposes, Vim maintains a swap file with a ".swp" extension during editing. When opening a file that already has an associated swap file, Vim alerts the user and generates additional swap files with extensions like ".swo" or ".swn" if necessary. Users can disable the swap file functionality if preferred.

Vim script

Vim script—also known as Vimscript or VimL—serves as Vim's native scripting language. It traces its roots back to the ex language used in the original vi editor. Early iterations of Vim introduced control flow constructs and function definitions. Starting with version 7, Vim script expanded to include complex data types such as lists and dictionaries, along with rudimentary object-oriented programming features. Functional programming elements are supported via built-in functions like map() and filter(), while lambda expressions have been incorporated since version 8.0. The scripting language predominantly follows an imperative paradigm.

Vim macros can contain commands executed in normal mode as well as ex commands or Vim script functions to perform intricate operations. The majority of Vim add-ons—referred to as plugins or scripts—are authored in Vim script; however, plugins may also be developed using languages such as Perl, Python, Lua, Ruby, Tcl, or Racket. Installation of these plugins can be done manually or through plugin managers like Vundle, Pathogen, or Vim-Plug.

Files containing Vim script are plain text documents bearing the .vim extension; the primary configuration file is named .vimrc.

Examples

<syntaxhighlight lang="vim"> " Displaying Hello World in Vim script. echo "Hello, world!"

" Basic while loop example in Vim script. let i = 1 while i < 5

 echo "count is" i
 let i += 1

endwhile unlet i </syntaxhighlight>

Availability

Initially developed for Unix environments, Vim has since been adapted to a wide range of platforms such as AmigaOS, Atari MiNT, BeOS, DOS, Windows (starting from NT 3.1), OS/2, OS/390, MorphOS, OpenVMS, QNX, RISC OS, Linux, various BSD variants, and the Classic Mac OS. Additionally, it comes pre-installed with Apple's macOS.

There are also independent Vim versions tailored for mobile operating systems like Android and iOS.

Neovim

Neovim represents a derivative project of Vim aimed at boosting extensibility and simplifying maintenance. It incorporates native support for the Language Server Protocol (LSP), asynchronous input/output operations through the C-based library libuv, and scripting capabilities using the luaJIT interpreter. These enhancements facilitate sophisticated plugin development and enable headless usage scenarios. The initiative is open source, licensed under the MIT License, with its source code available on GitHub.

Neovim preserves compatibility with the majority of Vim’s functionalities and employs the same configuration format as versions prior to vim9script, permitting shared configuration files with only slight option adjustments.

Launched in 2014 following the rejection of a multi-threading proposal for Vim, Neovim successfully raised funds that supported at least one dedicated developer full-time. Several user interfaces are being developed to take advantage of Neovim's features.

The July 2021 release of version 0.5 introduced integrated LSP support, incorporation of the Tree-sitter parsing system, and improved Lua integration including configuration through Lua scripts. Starting with version 0.9, Neovim added support for EditorConfig to ensure uniform coding styles across different projects.

See also

External links

  1. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
  2. ↑ 2.0 2.1 Cite error: Invalid <ref> tag; no text was provided for refs named :1
  3. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
  4. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
  5. ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).