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
3k 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&...
Runium's user avatar
  • 1,237
39 votes
2 answers
14k 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 ...
Anthony's user avatar
  • 501
14 votes
2 answers
265 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 ...
rlms's user avatar
  • 305
8 votes
2 answers
532 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 ...
user avatar
9 votes
1 answer
844 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 ...
Martin Tournoij's user avatar
6 votes
1 answer
427 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 ...
davidlowryduda's user avatar
6 votes
0 answers
829 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 ...
davidlowryduda's user avatar
116 votes
8 answers
139k views

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
1k 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, ...
Gilles 'SO- stop being evil''s user avatar
2 votes
1 answer
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 ...
Jim's user avatar
  • 265
9 votes
1 answer
1k 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 ...
tommcdo's user avatar
  • 7,680
7 votes
2 answers
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 " . ...
MattyW's user avatar
  • 173
9 votes
2 answers
3k 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 ...
jalanb's user avatar
  • 684
6 votes
1 answer
866 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 ...
Andrew Ferrier's user avatar

1
28 29 30 31
32