Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing vim to reload already loaded autoload vimfiles

Tags:

vim

centos7

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.

like image 487
Amarjeet Sharma Avatar asked Mar 06 '26 04:03

Amarjeet Sharma


1 Answers

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?

like image 121
romainl Avatar answered Mar 08 '26 22:03

romainl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!