How can I undo Ruby and Rails code in Vim?

I just wonder if it is possible in Auto Vim Auto-Rails Code instead:

validates :email, :presence => true, :format => { :with => email_regex }, :uniqueness => { :case_sensitive => false } 

:

 validates :email, :presence => true, :format => { :with => email_regex }, :uniqueness => { :case_sensitive => false } 
+6
source share
3 answers

The best way to do this is to actually not use the built-in alignment in Vim, but rather Dr. Align Plugin from Dr. Chip, which is used to horizontally align arbitrary characters in vertical columns.

1,3Align => will align, for example, to => . You can get detailed information about the order, etc., using the AlignCtrl function, but the degree of its functionality is probably left in the documentation. :)

+8
source

Thanks for answers.

If someone needs this, in Tabular it works with:

 :Tabularize /^[^:]*\zs:/r1c0l0 :Tabularize /^[^=>]*\zs=>/l1 

If you want to use this in a function in your vimrc:

 function IndentV() Tabularize /^[^:]*\zs:/r1c0l0 Tabularize /^[^=>]*\zs=>/l1 endfunction map <Leader>iv :call IndentV()<cr> 

So, you just select the text in visual mode and press \iv to make it happen.

+1
source

I use Align and Tabular plugins.

Align has some good pre-built alignments, while Tabular allows you to create a regular expression that will be used to match fields. These days I use Tabular more, but your mileage may vary.

0
source

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


All Articles