How to split .vimrc into separate files? For example, separate javascript related…
- User
How to split .vimrc into separate files? For example, separate javascript related plugins and configuration into a separate file and import it in the main .vimrc
- Assistant
To split your .vimrc into separate files, follow these steps:
- Create a new directory called
vim_settings(or any name of your choice) inside your~/.vimdirectory to store all your separate configuration files.
mkdir ~/.vim/vim_settings- Create separate configuration files for each category, in this example,
javascript.vim, inside thevim_settingsfolder:
touch ~/.vim/vim_settings/javascript.vim-
Move the JavaScript-related plugins and configuration from your
.vimrcfile into the newly createdjavascript.vimfile. -
In your
.vimrcfile, add the following command to "import" the configuration fromjavascript.vim:
source ~/.vim/vim_settings/javascript.vimThis
sourcecommand will execute the content ofjavascript.vimjust as if it was written directly in your.vimrcfile. - Create a new directory called