Align text on an equals sign in vim

后端 未结 9 2450
一生所求
一生所求 2020-12-12 22:48

I tend to align code on equal signs for better readability. From this:

$ = jQuery.sub()
Survey = App.Survey
Sidebar = App.Sidebar
Main = App.Main
         


        
9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 22:51

    This isn't the easiest way to do things, but it can be done without any plugins.

    • Use V and :s/=/ =/ to insert a bunch of spaces before each equals sign.
    • Use Ctrl-V to select the column that you want the equals signs to be moved into.
    • Press << to "unindent" the right hand side of each equation towards the column you selected, then press . repeatedly until the equals signs are lined up in that column.

提交回复
热议问题