Amarjeet Sharma
Amarjeet Sharma

Reputation: 188

Forcing vim to reload already loaded autoload vimfiles

I was trying to experiment on auto-load files which vim load at the time of start. I kept the example.vim file in:

~/.vim/autoload/

directory and written a very simple function as:

echom "Autoloading..."

function! cpp#running#CompileAndRunFile(commands)
    silent !clear
    execute "!" . a:commands . " " . bufname("%")
endfunction

function! cpp#running#DebuggersOptions()
    " Get the bytecode.
    let bytecode = system(a:command . " -E -o " . bufname("%"))

    " Open a new split and set it up.
    vsplit __Bytecode__
    normal! ggdG
    setlocal filetype=potionbytecode
    setlocal buftype=nofile

    " Insert the bytecode.
    call append(0, split(bytecode, '\v\n'))
endfunction

But I want to programatically force a reload of an autoload example.vim file which Vim has already loaded, without bothering the user. The reason being that I want that programmer at run-time can change behavior of the function and load latest modified function.

How can I do that ?

Thanks.

Upvotes: 3

Views: 956

Answers (1)

romainl
romainl

Reputation: 196526

auto-load files which vim load at the time of start.

No. The autoload feature is exactly the opposite: an autoloaded script is sourced at runtime, when a function it contains is called.

But I want to programatically force a reload of an autoload example.vim file which Vim has already loaded, without bothering the user.

:source it again?

Upvotes: 6

Related Questions