简体   繁体   English

ERB文件的VIM折叠?

[英]VIM folding for ERB files?

Vim noob here. Vim noob在这里。 I have code folding working in most places, via indent mode, but for some reason I cannot get Vim to fold .html.erb files in ruby... even with indents. 我在大多数地方都有代码折叠工作,通过缩进模式,但由于某些原因我无法让Vim在ruby中折叠.html.erb文件...即使有缩进。

Here's the relevant region of my vimrc. 这是我的vimrc的相关区域。 Is there something else I need to do to make Vim aware of the erb files? 还有什么我需要做的让Vim知道erb文件吗? Is it possible to customize my folding per file type? 是否可以自定义每种文件类型的折叠?

I'm running all the Janus plugins, so have rails.vim, etc. all installed. 我正在运行所有的Janus插件,所以安装了rails.vim等。

let ruby_fold=1
set foldmethod=indent
set foldcolumn=0
set foldlevel=99
nnoremap <space> za<cr>

It's a difficult question, because there's probably something in your vim configuration that inhibits folding and I, for example, can't reproduce it. 这是一个很难的问题,因为你的vim配置中可能存在一些禁止折叠的东西,例如,我无法重现它。 But I can suggest a few things you could try. 但我可以提出一些你可以尝试的事情。

First of all, check what the values of those settings are in the actual buffer. 首先,检查这些设置的值在实际缓冲区中的含义。 Meaning, open up an erb file and check if the settings are correct. 意思是,打开一个erb文件并检查设置是否正确。 In order to do that, you can type, for example, set foldmethod , which will echo the current value of foldmethod to the screen. 为了做到这一点,你可以输入,例如, set foldmethod ,将电流值呼应foldmethod到屏幕上。 If one of the settings doesn't match the ones in your .vimrc, then that might be the problem. 如果其中一个设置与.vimrc中的设置不匹配,则可能是问题所在。

Also, see if the file really does have the "eruby" filetype. 另外,查看该文件是否确实具有“eruby”文件类型。 If it's not displayed in your statusline, you could check that with set filetype . 如果它没有显示在您的状态行中,您可以使用set filetype检查它。

Most importantly, one way of customizing settings per filetype is by creating a file with the filetype's name inside the ~/.vim/ftplugin directory. 最重要的是,一种自定义每种文件类型设置的方法是在~/.vim/ftplugin目录中创建一个文件类型名称的文件。 In your case, you can create the file ~/.vim/ftplugin/eruby.vim and put any filetype-specific settings in it. 在您的情况下,您可以创建文件~/.vim/ftplugin/eruby.vim并在其中放置任何特定于文件类型的设置。 Setting them with setlocal instead of set will keep them local to the file. 使用setlocal而不是set设置它们将使它们保持文件本地。 If it turns out the settings for erb are off, you can "fix" them by putting the values you want there. 如果事实证明erb的设置已关闭,您可以通过在其中放置所需的值来“修复”它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM