Questions tagged [vimscript]

A scripting language embedded into Vim. It can be used to customize Vim to suit your needs and to create plugins. Also called VimL.

Filter by
Sorted by
Tagged with
4
votes
1answer
2k views

Vimscript save file

I am making a function to compile and run my application. I have been able to get it to run the shell command however I cannot get it to save the file. Here is my code so far. Try 1) function ...
9
votes
1answer
5k views

function to call shell script with arguments

I am making my own function to call a bash script that compiles and runs my program. Here is the code I have tried. function Compile_and_run(game, major, minor) !_compile a:game a:major a:minor ...
4
votes
1answer
624 views

Following a tag in a VimScript

I am working on an omni-completion script where I use taglist() to search for the existence of a certain word. After obtaining that tag I now need to quickly jump to where the tag is defined and ...
6
votes
1answer
599 views

Why don't I get syntax highlighting when I open a file in an autocmd?

While trying to devise a solution to How do I make vim look in a set of directories for a file, if it doesn't exist in the current directory?, I have got so far using Python: function LookupFiles ...
15
votes
2answers
2k views

Is cpo&vim a special syntax?

In scripts it is customary to do something like: let s:save_cpo = &cpo set cpo&vim ... script ... let &cpo = s:save_cpo To ensure nocompatible mode for the script. Is: set cpo&...
35
votes
2answers
10k views

What's the difference between let and set?

I don't know much of the theory behind Vim. It looks as if we set some variables, and let other variables. What's the difference, and when is one required over the other? Also, the solarized vim ...
14
votes
2answers
259 views

Automatically add a closing " or ' when inserting one, but only if the cursor isn't inside a string already

I've defined mappings in my vimrc to automatically enter close parentheses and braces when I enter opening ones with inoremap ( ()<esc>i. I'd like to do the same for " and ', but only when the ...
8
votes
2answers
348 views

Automatically delete closing pair without causing unbalanced pairs

I am writing a VimL function that, in insert mode, allows a <BS> through the opening part of a pair ([, {, etc.) to delete the closing part of the pair if it is the next character after the ...
7
votes
1answer
616 views

Can I pass a custom string to the 'gx' command?

I have a file like this: vi.stackexchange.com example.com duckduckgo.com I want to be able to open these sites with gx; this doesn't work because there's no protocol (http://) in front of these ...
4
votes
1answer
391 views

Making a box in vim via python

I am attempting to learn more about scripting vim and writing plugins with python, but I'm having trouble getting started. Although I've read :h python (first step, read the manual), I had trouble ...
6
votes
0answers
816 views

Resources for scripting vim with python [closed]

I love vim, I love python, and I dislike vimscript. So I would like to know how to write plugins (or throwaway scripts) for vim in python. Of course, the first reference should be :h python, but I ...
17
votes
4answers
777 views

Set the paste option, but for one insertion only

I want to have a quick way of setting the Vim 'paste' option, inserting some text, and reverting to the previous value of 'paste'. A typical use case insert the OS clipboard content literally, ...
2
votes
1answer
1k views

Autocommand groups syntax and usage [closed]

What are some of the ways to construct autocommand groups in the .vimrc? What is the benefit of grouping autocommands? Can you provide some materials on proper use of autocommand groups? Any help here ...
9
votes
1answer
925 views

Regex that prefers shorter matches within a match? (This is more involved than non-greedy)

I'm trying to create a script for performing fuzzy search inside a buffer. The main idea is to take some input, and insert .\{-} between every pair of characters, e.g. foo becomes f.\{-}o.\{-}o. This ...
7
votes
2answers
2k views

Jumping to a file in vimscript

Using gF I can jump to a file with the format foobar.py:27:6 to open foobar.py on line 27. My question is how I can make this jump in vimscript? For example, this won't work: execute "normal gF " . ...
6
votes
2answers
2k views

How do I search for a line that contains a pattern at column n

In writing some Vimscript to try to answer this question, I was exploring ways to "search for a line with pattern P in position X" (P is a search pattern, X is a number). One way to do this would be ...
5
votes
1answer
792 views

What is an effective way to learn vimscript? [closed]

Let's say I've been working with vim for some time; I've dabbled with my ~/.vimrc and copied-and-pasted some snippets in I find on the way, with minimal changes. I'm beginning to get a hazy ...

1
20 21 22 23
24