Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [functions]

Question about the use of functions in Vimscript defined in the `.vimrc` or a script file.

3
votes
1answer
599 views

Toggle fzf.vim if already open

I am trying to write a vim function to toggle the fzf window if it is already open using fzf.vim. The use case is if I am in the :Buffers view and I want to change to the :Files view if I try to ...
1
vote
1answer
70 views

function: sort output alphabetically

This function outputs data between braces as joined lines in a quickfix window. The output is sorted based on line numbers. I'm searching for a method to sort the data alphabetically. I tried to ...
8
votes
0answers
214 views

vim ZZ lost output with autocommand

I want to check file before quitinq vim with custom functions, everything seems fine with QuitPre autocommand except using ZZ to exit. In this case the output is missing. Consider following function ...
4
votes
0answers
182 views

system function output with Chinese chars

I want to run shell command with system function and the command output has some Chinese chars. echo system('svn status') But I got incorrect encoding output like this: svn: ?\232?\173?\166?\229?\...
3
votes
0answers
346 views

Getting balloonevalterm to work (terminal version)

I'm trying to get balloonevalterm to work in the terminal version of vim, but for some reason it does not yet work. Here's my macros.vim file: function! MyBalloonExpr() let macros = { \ 'MACRO' : ...
3
votes
0answers
44 views

Why does append(…, readfile()) add a zero when run using Ctrl-R?

While looking for ways to solve How can I create a /* comments section with /// like in XCode?, I cam across this puzzling behaviour. Say I have foo.txt containing: /*! * @author Robbie Yi JIANG, 29-...
2
votes
0answers
127 views

Vim function somehow adds Ctrl-j to macro?

I've written a short vim function that allows me to edit the contents of vim registers: fun! RegBuff() let vimstuff = "/tmp/vimstuff" if !isdirectory(vimstuff) call mkdir(vimstuff) ...
1
vote
0answers
47 views

Add conceal in function

Trying to maintain add conceals to the generated location list, but I can not figure it out. The current workaround is to add it manually everytime through the vim commandline, like: : set ...
1
vote
0answers
56 views

Monkey-patch plugin function

Is it possible to override an autoloaded plugin-function? I want to customize an airline-internal function just like this: diff --git a/autoload/airline/extensions/default.vim b/autoload/airline/...
1
vote
0answers
17 views

Determining syntax group type from output of 'syn list' (doesn't appear to work for regions)

Why does the output of syn list not include region in the syntax group definition line, like it does for 'match' type groups? What is the meaning of the xxx in that line? I've got a vim 8.0 function ...
1
vote
0answers
171 views

Search not working in function called from autocmd

I am quite new to using vim so please forgive me if this has been asked else where. I have tried Googling but am not really sure what to search for. In my vimrc I have the follwing function that ...
1
vote
0answers
196 views

Vimrun.exe keeps opening and closing when statusline is updated

I am working on a plugin and as part of that plugin I am trying to update the statusline with setlocal statusline=%!GetMPCStatusline(). But this causes vimrun.exe to open and close very fast. This ...
0
votes
0answers
31 views

How to stop a function when <esc> is pressed? OR how to catch a <esc> signal in vimscript?

I have a function which calls another function that reads user input from input(). function! fun1() call fun2() endfunction function! fun2() let temp = input("Please input:") endfunction What I ...
0
votes
0answers
94 views

Exclamation mark after autocommands

I'm trying to understand what does exclamation mark after autocommands mean. Sometimes it is possible to see something like this: function! LangSpecificOptions() if (&filetype == 'markdown' || ...
0
votes
0answers
35 views

Why is this function clearing screen output?

This is an example script which is meant to print the keyboard shortcut for a command. Applying it clears the screen output. The result of commands like intro or version get cleared off the screen ...