Loading ...
Sorry, an error occurred while loading the content.

Re: Align Ruby Hash

Expand Messages
  • Charles E Campbell Jr
    ... Hello! Try ... will yield @myobject.someproperty = {: first_name= Bob , ... I m not sure what you actually wanted as the lines I received as shown above
    Message 1 of 2 , Jan 31, 2008
      Nate wrote:

      >I'm currently trying to use the Align plugin to format a ruby hash
      >declaration, and would appreciate any hints.
      >Here's a sample of non-formatted ruby hash declaration:
      >@... = { :first_name => 'Bob',
      >:last_name => 'DogWorthy', :age => 34,
      > :occupation => 'programmer}
      >Here's what I want:
      >@... = { :first_name => 'Bob',
      > :last_name =>
      >'DogWorthy', :age => 34,
      > :occupation =>
      >Here's my 1st attempt at creating an Align Ctrl. The abundance of =>
      >=> => means that I only want to use the first colon as a separator, so
      >that the first colons line up.
      >AlignCtrl lllp1P011111C : => => => => =>
      >It works fairly well, but I would like to see if I could do some
      >additional things, like fix commas that are out of place. For
      >example, I would like to fix this:
      >:first_name = 'Bob' ,
      >to be this
      >:first_name = 'Bob',
      >Any ideas? Thanks to Charles, who created the plugin. It works
      >really well once you understand it.


      :AlignCtrl lp1P0C
      :[range]Align : =>

      will yield

      @... = {: first_name=> 'Bob',
      : last_name => 'DogWorthy',: age=> 34,
      : occupation=> 'programmer}

      I'm not sure what you actually wanted as the lines I received as shown
      above are broken into parts and perhaps the spacing is odd. What are
      all the 1s for?

      To fix things like commas and whatnot, you probably should follow the
      AlignCtrl/Align with a substitute. Put the whole thing in a map, and
      then it'll be easy to invoke, too. After all, that's basically what the
      various maps in AlignMaps do.

      Chip Campbell

      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.