Programming Languages Section

Vimscript

Card image
Post by Amina Delali, September 19th,2021

Some Facts

Vimscript is the internal scripting language of the Vim Editor. Also called VimL, Vimscript is an imperative dynamic scripting language that offers the usual programming language features like built-in and user defined functions as well as high level data structures.

Vimscript code can be executed within a Vim session. It is also used in the editor’s initialization file to change for example the default keymapping. It also can be used to create plugins to extend the functionalities of the editor.



How to install it

  • on Windows:

    You will have to install the Vim Editor. To do that, just follow these steps:

    1. got to this  vim download page.
    2. select the current and recent stable Ms-Windows version and download it (you will download an installer)
    3. run and follow the steps of the installer.
  • on ubuntu :
    • Again, as for Windows 10, just install the Vim Editor. Open the terminal then type in and run the following commands: sudo apt update
      sudo apt install vim
    • To check the installation of Vim, run the following command: vim -version

In the video below, the details of the installation of the Vimscriptlanguage on Ubuntu.

The Hello World Example

  1. open the terminal from the Home folder, then use the following vim command to open the vim editor and and at the same time, to create a file with the name “Hello.vim : vim Hello.vim
  2.  in the current file, write the following line (after typing a for insert mode): :echo "Hello World!"
  3.  click on the escape key then type the command :w to save the file. After that, to run your script, type and run the following command:
    :so % 
  4. You can use another command instead (with the same result): :source Hello.vim 
  5. You can exit (:q) and try again. Run first the command vim to open the editor :vim
  6. Then type in the following command: :source Hello.vim

For more information about the vimscript, you can visit one of these following pages: page 1, page 2, or page 3.



Additional Information

Something to say ?

If you want to add something about the Vimscript language or about this post, please feel free to do it by commenting below 🙂 .