Questions tagged [viml]

VimL, or VimScript, is the scripting language used to program (and configure) the Vim editor.

Both Vim plugins (scripts) and the Vim configuration-files (such as .vimrc) are written in VimL.

VimL, as a programming language, is a imperative language with support for (as of version 7) a simplified form of object-oriented programming. Scripts written in VimL can both invoke ‘normal-mode’ commands, as well as calling more complex ex commands or more complicated functions combining such functionality.

Vim can also be scripted with other programming languages (depending on which compile-time features a particular user has selected); but the vast majority of popular extensions and plugins are written in VimL.

VimL files are plain-text, and use .vim as a file-extension.

Vimscript : Offers most of the usual language features: variables, expressions, control structures, built-in functions, user-defined functions, first-class strings, high-level data structures (lists and dictionaries), terminal and file I/O, regex pattern matching, exceptions, and an integrated debugger.

Several, popular, tutorials, are available, although a comprehensive, centralized documentation exists only in the form of the Vim user-manual itself.

Note: There is some confusion about the official name of this language. ‘VimL’, while currently a little less common, is chosen as the name on sites like GitHub and Stack Overflow, as it is less ambiguous to search for.

Vim Documentation

41 questions
69
votes
4 answers

VimScript or VimL?

What is the correct name of the Vim scripting language? I see it being called VimScript, Vim script and even VimL. VimL is even listed on GitHub as the 10th most popular programming language! What is the history behind the VimL name? Why are the Git…
Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292
37
votes
4 answers

vimscript call vs. execute

In vimscript, what is the difference between call and execute? In what scenarios / use cases should I use one vs the other? (Disclaimer, I am aware of the extensive online help available within vim - I am seeking a concise answer to this specific…
noahlz
  • 10,202
  • 7
  • 56
  • 75
21
votes
1 answer

regex in vimscript

let test = 'a href="http://www.google.com">www.google.com
guest
  • 437
  • 1
  • 5
  • 12
10
votes
2 answers

Vim: Remap key to move to the next non-blank line (and vice versa)

I'm looking for a way to remap a key to move the cursor down to the next line, skipping any lines that only contain \n and a way to do the same only going up to the next line. Essentially, I want to do the opposite of the { and } motions.
HaySwim
  • 103
  • 5
9
votes
3 answers

Vimscript: find last open parenthese or bracket

I'd like to write a function in vimscript that finds the last open parenthese or bracket in a line. This isn't necessarily an easy problem, because it needs to be able to handle all of the following: function(abc function(abc, [def function(abc,…
So8res
  • 9,856
  • 9
  • 56
  • 86
7
votes
3 answers

Vimscript: Number of listed buffers

In my vimscript, I need to get a count of all buffers that are considered listed/listable (i.e. all buffers that do not have the unlisted, 'u', attribute). What's the recommended way of deriving this value?
Jonathan
  • 123
  • 2
  • 9
6
votes
2 answers

How can I check if a Vim buffer is modifiable?

I find the Vim shortcuts nmap o or nmap O, which insert a blank line with the enter key, very useful. However, they wreak havoc with plugins; for instance, ag.vim, which populates the quickfix list with filenames to jump…
Sasgorilla
  • 2,403
  • 2
  • 29
  • 56
6
votes
1 answer

How to send escape sequences from within Vim?

So recently Apple have included support for displaying the working directory and file in the status bar of Terminal. The escape sequence that must be sent (to set the current file) is this: ESC ] 6 ; Pt BEL where Pt is a file:// url pointing to the…
felixphew
  • 6,023
  • 2
  • 22
  • 33
5
votes
0 answers

How to set a transparent background for Vim with "true color" enabled?

I've enabled true colors for Vim with success using: set t_8f=\[[38;2;%lu;%lu;%lum set t_8b=\[[48;2;%lu;%lu;%lum set termguicolors (check :h xterm-true-color for more information) I have then enabled a true color colorscheme to try the new setting,…
oblitum
  • 11,380
  • 6
  • 54
  • 120
5
votes
2 answers

Parse a date in VimScript

Given a date string of the form "2012-09-31", I'd like a vimscript function to parse it so I can calculate relative dates. Pure vimscript or python solutions are welcome.
Dave Ray
  • 39,616
  • 7
  • 83
  • 82
4
votes
2 answers

Vimscript print function?

Is there a function in Vimscript or a convention that allows you to simply print text to the editor? The function echo only supplies a command line print function, and does not actually print to the editor.
beakr
  • 5,709
  • 11
  • 42
  • 66
3
votes
1 answer

Define a syntax region which depends on the indentation level

I'm trying to built a lighter syntax file for reStructuredText in Vim. In rst, literal blocks start when "::" is encountered at the end of a line: I'll show you some code:: if foo = bar then do_something() end Literal blocks end…
Silas
  • 392
  • 1
  • 4
  • 15
2
votes
2 answers

Open a buffer on a new Tab on Vim

I'm creating a Vim plugin that I need intercept when a new buffer is loaded. The basic idea consists in when I open a new buffer this new buffer must be screened on another tab, and the previous tab must keep the previous buffer loaded. Eg.: I have…
Samuel Simões
  • 141
  • 1
  • 2
  • 13
2
votes
1 answer

How to open files recursively excluding some directories using args in vim?

I want to open all files in a directory recursively excluding some subdirectories. For example, I want to exclude all files under directories named "inbox" in any level. I can specify which directories I want to include. Is there a way to specify…
Mert Nuhoglu
  • 9,695
  • 16
  • 79
  • 117
2
votes
1 answer

Different command based on if next line is empty

I'm trying to auto-add ; , or whatever is needed in the end of expression by a keystroke, and go to another line. Basicly it'll be something like inoremap ; A;, but i want a little improvement. If next line is empty (or doesn't exist) i…
sheikh_anton
  • 3,422
  • 2
  • 15
  • 23
1
2 3