i try to collect my .vimrc files into single file is there anyway to generate single file using vimscript depending on source vimscript keyword or python code

example of my .vimrc

if isdirectory($HOME."/.config/vim/")
  for configfile in split(glob($HOME."/.config/vim/*.vim"), "\n")
    execute "source " configfile

i put vim configs in separated files under ~/.config/vim/ directory and source them from .vimrc file

  • You'd need to do the check by source recursively; worse, if you really want everything, you'd have to read in everything under plugin, and all the other stuff grouped in appropriate autocommands, etc. This is hard to get right, and I confess I don't see the point. The structure of .vim and :help runtimepath is there for a reason
    – D. Ben Knoble
    Feb 10 at 13:45
  • 1
    Please edit add more details to clarify what it is you are trying to accomplish: There is only one vimrc file. But you mention multiple and the source command. Could you give an example layout that you are trying to collapse together? (Welcome to Vi and Vim, by the way!)
    – D. Ben Knoble
    Feb 10 at 13:51
  • 1
    Well, for that I would do one of two things: find ~/.config/vim -type f -print0 | xargs -0 cat > ~/.vim/vimrc, or put them in ~/.vim/plugin where they will be sourced automatically after your vimrc.
    – D. Ben Knoble
    Feb 10 at 14:11
  • well, thanks for answering me, but this not work if the files that i source also source other files the output file of this command find ~/.config/vim -type f -print0 | xargs -0 cat > ~/.vim/vimrc will include source statement Feb 10 at 14:18
  • 1
    You can remove the sources with something like :g/source/d afterwards?
    – D. Ben Knoble
    Feb 10 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.