Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 6189

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

2 votes
1 answer
266 views

What does `_` do in this map() expression?

I'm trying to understand the code suggested in https://vi.stackexchange.com/a/28506/6189: function MyLinks(pat, spat, ssub, sflags) abort return glob(a:pat, v:false, v:true) \ ->map({_, v -> …
alec's user avatar
  • 835
2 votes
2 answers
111 views

why are variabes prefixed with `a:`?

I'm trying to understand the code suggested in https://vi.stackexchange.com/a/28506/6189: function MyLinks(pat, spat, ssub, sflags) abort return glob(a:pat, v:false, v:true) \ ->map({_, v -> …
alec's user avatar
  • 835
6 votes
2 answers
1k views

What is `v` in this vimscript?

I'm trying to understand the code suggested in https://vi.stackexchange.com/a/28506/6189: function MyLinks(pat, strip) abort return glob(a:pat, v:false, v:true) \ ->map({_, v -> printf('[%s] …
alec's user avatar
  • 835
0 votes

How to conditionally re-bind <Enter> key depending on file?

autocmd BufRead /path/to/file*.type is indeed the correct logic... but there are two problems here. First, is the syntax... the lines starting with \ are odd... entering the full command like autocmd …
alec's user avatar
  • 835
0 votes
2 answers
221 views

How to conditionally re-bind <Enter> key depending on file?

wiki-tag-reports/some-tag-report.mkd open the Enter key should trigger that vimscript function instead of the vimwiki's usual enter-key function. … I don't know how to approach such a "conditional" loading of vimscript. Currently/previously I was using two separate vimrc's but that doesn't work in this switching-back-and-forth way. …
alec's user avatar
  • 835
1 vote
0 answers
75 views

embed one text file in another and edit the embedded file from the file it's embedded in

Is there any existing plugin or gist somewhere that would allow you to embed one text file inside another? Ideally it'd also allow editing the embedded file from the file in which it is embedded. Thi …
alec's user avatar
  • 835
4 votes
1 answer
994 views

how to loop through list of files?

I can do :echo globpath('~/path/to/dir', 'string*') to get a list like: /home/alec/path/to/dir/string_xyz123.mkd /home/alec/path/to/dir/string_xyz456.mkd /home/alec/path/to/dir/string_xyz789.mkd but …
alec's user avatar
  • 835
0 votes
1 answer
3k views

how to use variables in vimscript shell commands

I've looked through various posts on the stack network but I haven't seen any examples using a vimscript variable (like task_id in my case) inside a shell command's arguments. …
alec's user avatar
  • 835
7 votes
1 answer
3k views

how to include multiple commands nested inside a single `autocmd BufRead...`?

I want to make several keybinds and options set for certain files based on their location. Is there a more elegant way than... autocmd BufRead,BufNewFile /tmp/wiki-tag-reports/* nnoremap <Enter> :Dia …
alec's user avatar
  • 835
3 votes
1 answer
733 views

why doesn't regex work in vimscript (while it does in normal search)?

But that same regex in my vimscript doesn't work. …
alec's user avatar
  • 835
3 votes
Accepted

why doesn't regex work in vimscript (while it does in normal search)?

One of the links referenced put the expression in double quotes ". Using single quotes ' instead fixes the problem with if line =~ '^\(\a\)\{1,}$'. In order for match() to be used in logic like this …
alec's user avatar
  • 835
2 votes
1 answer
2k views

VimWiki - create a "smart" index page for subdir/section of wiki?

I'm using VimWiki for a writing project and for certain sections (like "chapters", contained in sub-directories) I want to create indexes that work similarly to the way VimWiki's diary index works. U …
alec's user avatar
  • 835