0

I outsourced a few sections of my .vimrc to .vim/custom/binds/foo.vim to seperate binds for different languages. I know about after but I want to keep the structure I am currently using.

I often find my self changing mappings in foo.vim while working in some file.foo, and don't want to close and reopen file.foo file every time I make changes to foo.vim.

I have noremap \c0 <Esc>:source<Space>~/.vimrc<Enter> in my .vimrc and it performs exactly what I want for the mappings in the rc.

I tried to include runtime! custom/binds/*.vim but this does not seem to work. Not even when executed manually.


:help runtime:

When {file} contains wildcards it is expanded to all
                        matching files.  Example:
                                :runtime! plugin/*.vim

what am I missing here?


edit:

inside my .vimrc I :source ~/.vim/custom/binds/foo.vim. so sourcing works fine, but I have to do this for every file seperatly.

1 Answer 1

2

Why don't you use the standard .vim/plugin/ and .vim/ftplugin/{ft}/ ? It's their exact purpose.

  • plugins are loaded once when Vim starts
  • ftplugins are loaded every time you open a file, or create a new buffer, that matches the associated filetype.

Don't mix up the official plugins scripts with the plugins managed by plugin managers. The second kind are just bundles of a set the first kind distributed among specific sub-directories. These specific sub-directories can (and must) also be used for your own configuration.

You'll also be interested in this SO Q/A that also discusses reloading scripts -- three reloading solutions are indirectly provided: my :Reload helper command, Tim Pope's vim-scriptstrease, and Ingo Karkat's ReloadScript.

1
  • Ok I will give it a try, but I actually wanted to keep them where they are now. Loading the files on start-up is also not my problem. I source all relevant files in my .vimrc. What I wanted to do is to reload all these Scripts WITHOUT reopening the file I am currently working on when I change a relevant .vim file. Currently I have maped \c0 to :source ~/.vimrc<Enter>. But that somehow wont run the :source commands inside the .vimrc. So I wanted to include my custom bindings into that binding \c0 to reload all other files as well
    – omnesia
    Aug 11, 2017 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.