Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Vim (text editor)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Vim script == '''Vim script''' (also called '''Vimscript''' or '''VimL''')<ref>{{cite web|url=https://pragprog.com/book/bkviml/the-viml-primer|access-date=25 January 2020|title=The VimL Primer: Edit Like a Pro with Vim Plugins and Scripts by Benjamin Klein | The Pragmatic Bookshelf|last=Klein|first=Benjamin|url-status=dead|archive-url=https://web.archive.org/web/20200125123547/https://pragprog.com/book/bkviml/the-viml-primer|archive-date=25 January 2020}}</ref> is the [[scripting language]] built into Vim.<ref>{{cite web|url=https://vimhelp.org/usr_41.txt.html|title=Vim documentation: usr_41|website=vimhelp.org|access-date=13 January 2019|archive-date=13 January 2019|archive-url=https://web.archive.org/web/20190113232237/https://vimhelp.org/usr_41.txt.html|url-status=live}}</ref> Based on the [[Ex (text editor)|ex]] editor language of the original [[Vi (text editor)|vi]] editor, early versions of Vim added commands for control flow and function definitions. Since version 7, Vim script also supports more advanced data types such as [[List (abstract data type)|lists]] and [[Associative array|dictionaries]] and a simple form of [[object-oriented programming]]. Built-in functions such as <code>map()</code> and <code>filter()</code> allow a basic form of [[functional programming]], and Vim script has [[Anonymous function|lambda]] since version 8.0. Vim script is mostly written in an [[Imperative programming|imperative programming style]]. Vim [[Macro (computer science)|macros]] can contain a sequence of ''normal-mode'' commands, but can also invoke ex commands or functions written in Vim script for more complex tasks. Almost all extensions (called plugins or more commonly scripts) of the core Vim functionality are written in Vim script, but plugins can also utilize other languages like [[Perl]],<ref>{{cite web | url = http://vimdoc.sourceforge.net/htmldoc/if_perl.html | title = Vim documentation: if_perl | access-date = 2019-08-27 | last1 = Verdoolaege | first1 = Sven | last2 = Gerassimof | first2 = Matt | archive-date = 8 February 2012 | archive-url = https://web.archive.org/web/20120208154924/http://vimdoc.sourceforge.net/htmldoc/if_perl.html | url-status = live }}</ref> [[Python (programming language)|Python]],<ref>{{cite web | url = http://vimdoc.sourceforge.net/htmldoc/if_pyth.html | title = Vim documentation: if_pyth | access-date = 2019-08-27 | last = Moore | first = Paul | archive-date = 22 August 2012 | archive-url = https://web.archive.org/web/20120822072929/http://vimdoc.sourceforge.net/htmldoc/if_pyth.html | url-status = live }}</ref> [[Lua (programming language)|Lua]],<ref>{{cite web | url = http://vimdoc.sourceforge.net/htmldoc/if_lua.html | title = Vim documentation: if_lua | access-date = 2019-08-27 | last = Carvalho | first = Luis | archive-date = 30 March 2012 | archive-url = https://web.archive.org/web/20120330221044/http://vimdoc.sourceforge.net/htmldoc/if_lua.html | url-status = live }}</ref> [[Ruby (programming language)|Ruby]],<ref>{{cite web | url = http://vimdoc.sourceforge.net/htmldoc/if_ruby.html | title = Vim documentation: if_ruby | access-date = 2019-08-27 | last = Maeda | first = Shugo | archive-date = 14 February 2012 | archive-url = https://web.archive.org/web/20120214174436/http://vimdoc.sourceforge.net/htmldoc/if_ruby.html | url-status = live }}</ref> [[Tcl]],<ref>{{cite web | url = http://vimdoc.sourceforge.net/htmldoc/if_tcl.html | title = Vim documentation: if_tcl | access-date = 2019-08-27 | last = Wilken | first = Ingo | archive-date = 24 August 2012 | archive-url = https://web.archive.org/web/20120824172051/http://vimdoc.sourceforge.net/htmldoc/if_tcl.html | url-status = live }}</ref> or [[Racket (programming language)|Racket]].<ref>{{cite web | url = http://vimdoc.sourceforge.net/htmldoc/if_mzsch.html | title = Vim documentation: if_mzsch | access-date = 2019-08-27 | last = Khorev | first = Sergey | archive-date = 14 April 2012 | archive-url = https://web.archive.org/web/20120414232343/http://vimdoc.sourceforge.net/htmldoc/if_mzsch.html | url-status = live }}</ref> These plugins can be installed manually, or through a plugin manager such as Vundle, Pathogen, or Vim-Plug. Vim script files are stored as plain text, similarly to other code, and the filename extension is usually <code>.vim</code>. One notable exception to that is Vim's config file, <code>.vimrc</code>. === Examples === <syntaxhighlight lang="vim"> " This is the Hello World program in Vim script. echo "Hello, world!" " This is a simple while loop in Vim script. let i = 1 while i < 5 echo "count is" i let i += 1 endwhile unlet i </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)