Ruby on rails 3 source~/.vimrc正在文件中工作,但不会自动为coffee提供源代码

Ruby on rails 3 source~/.vimrc正在文件中工作,但不会自动为coffee提供源代码,ruby-on-rails-3,vim,coffeescript,macvim,Ruby On Rails 3,Vim,Coffeescript,Macvim,我为vim添加了coffee语法和缩进插件。这是我的~/.vimrc: colorscheme peachpuff syntax on filetype on source /Users/(myusername)/.vim/vim-coffee-script-master/indent/coffee.vim source /Users/(myusername)/.vim/vim-coffee-script-master/syntax/coffee.vim au BufNewFile,BufRe

我为vim添加了coffee语法和缩进插件。这是我的~/.vimrc:

colorscheme peachpuff
syntax on
filetype on
source /Users/(myusername)/.vim/vim-coffee-script-master/indent/coffee.vim
source /Users/(myusername)/.vim/vim-coffee-script-master/syntax/coffee.vim

au BufNewFile,BufRead *.js set filetype=javascript
au BufNewFile,BufRead *.coffee set filetype=coffee
au BufNewFile,BufRead *.rake set filetype=ruby
au BufNewFile,BufRead *.rb set filetype=ruby
au BufNewFile,BufRead Gemfile set filetype=ruby
au BufNewFile,BufRead Guardfile set filetype=ruby
au BufNewFile,BufRead *.less set filetype=scss

set autoindent
set expandtab
set softtabstop=2
set shiftwidth=2

当我打开一个.coffee文件时,它没有语法高亮显示。然后,我在文件中运行
:so~/.vimrc
,此时语法高亮显示。另外,当我拆分屏幕并在一个窗口中运行
:so~/.vimrc
时,它在另一个窗口中消失。有什么想法吗

.vimrc
文件用于全局设置。通过在那里寻找特定于咖啡的脚本,您只能在启动期间临时将它们应用到裸Vim;您打开的任何文件都不受此影响


相反,Vim有一个复杂的机制来检测各种类型的编程语言和其他文件类型;cp.
:帮助文件类型
。语法文件应放在
~/.vim/Syntax/
中,并缩进到
~/.vim/indent/
中。然后,一旦您
:setf coffee
(或者如果为
*.coffee
定义了检测),它将自动激活。

您是否尝试将语法文件放入~/.vim/syntax?你不需要设置自动命令。我知道这并不是你想要的,但可能会有所帮助。首先,你应该得到一个像Vundle这样的插件管理器。其次,您实际上不需要设置auto命令。第三,如果您使用Vundle或类似工具,则无需手动获取文件的源代码。此外,如果您不想使用Vundle或Vundle,则至少将其放入正确的文件夹中,即
~/.vim/indent
~/.vim/syntax
。您最后的评论对我很有用。谢谢你。现在我明白了为什么它们不能在子目录中。