将Vim config拆分为多个文件

将Vim config拆分为多个文件,vim,text-editor,vim-plugin,Vim,Text Editor,Vim Plugin,以下是我的配置的一部分: call plug#begin('~/.vim/plugged') " Here I want to split my Vim config into multiple files " I'm including other Vim configuration files for f in glob('.vim/*.vim', 0, 1) execute 'source' f endfor call plug#end() 它在主目录下工作得非常好 但是当

以下是我的配置的一部分:

call plug#begin('~/.vim/plugged')

" Here I want to split my Vim config into multiple files
" I'm including other Vim configuration files

for f in glob('.vim/*.vim', 0, 1)
    execute 'source' f
endfor

call plug#end()
它在主目录下工作得非常好

但是当我从带有我的项目的目录运行Vim时,例如cd~/Dev/my project&&Vim,~/.Vim/*.Vim文件中的所有配置和插件都不起作用

Vim仅使用~/.vimrc中的配置。执行不起作用

我怎样才能解决这个问题?我想将我的Vim配置拆分为多个文件

将您的文件放入$HOME/.Vim/plugin,这就是它的用途。你可能还想看看ftplugins等等

for f in glob('~/.vim/*.vim', 0, 1)
    execute 'source' f
endfor

我很确定在SO或vi.SE上有一个Q/a描述了如何将配置拆分为多个文件的最佳实践。

我认为您应该使用globpath函数。就像:

for f in globpath('~/.vim', '*.vim', 0, 1, 0)
    execute 'source' f
endfor

目录插件的路径是什么?@Meninx-メネンックス~/.vim/自动加载/插塞。vim@Meninx-メネンックス看来这不是vim插头的问题。例如,如果我将set number放入~/.vim/snippets.vim中,我将看不到任何行号这一点,再加上有效地使用rtp结构