I have split my .vimrc into several files and placed them into ~/vimfiles/vimrc.d/
.
Currently I source each file in that directory using exact name:
source ~/vimfiles/vimrc.d/file1.vim source ~/vimfiles/vimrc.d/file2.vim
etc.
How to make a loop thourgh all files in that directory so i could only have to do such loop in my .vimrc:
for file in ~/vimfiles/vimrc.d/*.vim source file enfor
As said by others: by default it saves in the directory where you started it. But if you aren't aware in which directory you started, then a way to find out is to use the :pwd com in vim. This will output the current directory. That's where vim will store the file.
In normal mode, type :e then press Space and Ctrl-D. That will list file names in the current directory.
You need to create the . vim folder in your home folder. All plugins will go into the ~/. vim/plugins folder.
The :source command will read the file and interpret the VimScript instructions in it, so this command will effectively load the vim plug-in into your current vim session. Thanks for simple answer.
As mb14 has already said, if you put them in ~/.vim/plugin
they will be sourced automatically. For information, however, if you want to source all of the files in your vimrc.d directory, you could do this (requires a relatively recent Vim):
for f in split(glob('~/vimfiles/vimrc.d/*.vim'), '\n') exe 'source' f endfor
You may also be interested in the autoload mechanism, described in :help 41.15
: if you're defining a lot of functions, this can make start-up a bit quicker as the functions are only loaded the first time they're used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With