Indented ERB Tags in Vim

I recently switched to Vim, and after the first hurdle I really liked it. The only thing that could be the deal killer for me is automatic indentation for erb tags, which are all messed up. I am using the Janus plugin package which includes ruby.vim and rails.vim. I also added html5.vim because someone told me this could help with this.

Here, and an example of confused indentation, he does:

<% unless @zipcode.latitude.blank? %> <p> <b>Latitude:</b> <%= @zipcode.latitude %> </p> <% end %> <p> <b>Longitude:</b> <%= @zipcode.longitude %> </p> 

Any suggestions in general would be highly appreciated. It seems like there should be a way to make a powerful editor like vim indent. I would not want to return to the sublime or aptane, but this is a feature from which I really do not want to live.

+4
source share
1 answer

I believe that there are 2 possible ways to solve your problem.

First, temporarily remove the Janus distribution and replace it with a minimum of .vimrc . Then install the ERuby plugin and see if it works. If it works now, the problem should be in conflict with one of the other plugins, and you should try to reconnect the different Janus plugins one by one to see where the error is. However, if it still does not work, you know that the plugin itself does not work on your system, and you can send a detailed error report to the author (including the operating system you are using and the version of vim).

Alternatively, it is very easy to reconfigure Vim to use a different indentation method. You can use another built-in indent ( :h indentexpr ), for example for XML:

 autocmd FileType eruby setl indentexpr=XmlIndentGet(v:lnum,1) 

Or you can configure Vim to use an external indentation program ( :h equalprg ).

+2
source

Source: https://habr.com/ru/post/1440637/


All Articles