3

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.

1 Answer 1

6

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?

Sign up to request clarification or add additional context in comments.

2 Comments

So Do i need to write autocmd on bufferwrite in .vimrc to source the particular file? Like: au BufWritePost example.vim :source example.vim
That's something to try, yes. You could use <afile> in place of the second example.vim, though.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.