Vimscript
Encyclopedia
Vimscript, also Vim script, is the scripting language
Scripting language
A scripting language, script language, or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the...

 built into Vim
Vim (text editor)
Vim is a text editor written by Bram Moolenaar and first released publicly in 1991. Based on the vi editor common to Unix-like systems, Vim is designed for use both from a command line interface and as a standalone application in a graphical user interface...

. Based on the ex
Ex (text editor)
ex, short for EXtended, is a line editor for Unix systems.The original ex was an advanced version of the standard Unix editor ed, included in the Berkeley Software Distribution...

 editor language of the original vi
Vi
vi is a screen-oriented text editor originally created for the Unix operating system. The portable subset of the behavior of vi and programs based on it, and the ex editor language supported within these programs, is described by the Single Unix Specification and POSIX.The original code for vi...

 editor, early versions of Vim added commands for control flow and function definitions. Since version 7, Vimscript also supports more advanced data types such as Lists and Dictionaries
Associative array
In computer science, an associative array is an abstract data type composed of a collection of pairs, such that each possible key appears at most once in the collection....

 and (a simple form of) object-oriented programming
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

. Built-in functions such as map and filter allow a basic form of functional programming
Functional programming
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...

, but Vimscript is mostly written in an imperative programming style
Imperative programming
In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state...

.

Vim macro
Macro
A macro in computer science is a rule or pattern that specifies how a certain input sequence should be mapped to an output sequence according to a defined procedure...

s can contain a sequence of normal-mode commands, but can also invoke ex commands or functions written in Vimscript for more complex tasks. Almost all extensions (called plugins) of the core Vim functionality are written in Vimscript, but plugins can also utilize other scripting languages like Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

, Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

 or Lua (if support for them is compiled into the Vim binary).

Vimscript files are stored in plain text format and the file name extension is .vim.

Example


let i = 1
while i < 5
echo "count is" i
let i += 1
endwhile

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK