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
18 votes
2 answers

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&...
Runium's user avatar
  • 1,237
39 votes
2 answers

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 ...
Anthony's user avatar
  • 501
14 votes
2 answers

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 ...
rlms's user avatar
  • 305
8 votes
2 answers

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 ...
user avatar
9 votes
1 answer

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

I have a file like this: 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 ...
Martin Tournoij's user avatar
6 votes
1 answer

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 ...
davidlowryduda's user avatar
6 votes
0 answers

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 ...
davidlowryduda's user avatar
116 votes
8 answers

How to edit binary files with Vim?

Is there a way to edit binary files in some kind of hexadecimal mode? For example if I have some binary data shown by xxd or hexdump -C like this: $ hexdump -C a.bin | head -n 5 00000000 cf fa ed ...
janos's user avatar
  • 2,808
19 votes
4 answers

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, ...
Gilles 'SO- stop being evil''s user avatar
2 votes
1 answer

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 ...
Jim's user avatar
  • 265
9 votes
1 answer

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 ...
tommcdo's user avatar
  • 7,680
7 votes
2 answers

Jumping to a file in vimscript

Using gF I can jump to a file with the format to open on line 27. My question is how I can make this jump in vimscript? For example, this won't work: execute "normal gF " . ...
MattyW's user avatar
  • 173
9 votes
2 answers

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 ...
jalanb's user avatar
  • 684
6 votes
1 answer

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 ...
Andrew Ferrier's user avatar

28 29 30 31