junegunn/vim-easy-align

Incorrect alignment in visual block mode

Addisonbean opened this issue · 0 comments

I am trying to align the following code:

  ((modMask .|. controlMask, xK_Right), sendMessage $ ExpandTowards R)
, ((modMask .|. controlMask .|. shiftMask, xK_Right), sendMessage $ ShrinkFrom R)
, ((modMask .|. controlMask, xK_Left), sendMessage $ ExpandTowards L)
, ((modMask .|. controlMask .|. shiftMask, xK_Left), sendMessage $ ShrinkFrom L)
, ((modMask .|. controlMask, xK_Down), sendMessage $ ExpandTowards D)
, ((modMask .|. controlMask .|. shiftMask, xK_Down), sendMessage $ ShrinkFrom D)
, ((modMask .|. controlMask, xK_Up), sendMessage $ ExpandTowards U)
, ((modMask .|. controlMask .|. shiftMask, xK_Up), sendMessage $ ShrinkFrom U)
, ((modMask, xK_r), sendMessage BSP.Rotate)
, ((modMask, xK_s), sendMessage BSP.Swap)

And I want to end up with this:

  ((modMask .|. controlMask,               xK_Right), sendMessage $ ExpandTowards R)
, ((modMask .|. controlMask .|. shiftMask, xK_Right), sendMessage $ ShrinkFrom R)
, ((modMask .|. controlMask,               xK_Left), sendMessage $ ExpandTowards L)
, ((modMask .|. controlMask .|. shiftMask, xK_Left), sendMessage $ ShrinkFrom L)
, ((modMask .|. controlMask,               xK_Down), sendMessage $ ExpandTowards D)
, ((modMask .|. controlMask .|. shiftMask, xK_Down), sendMessage $ ShrinkFrom D)
, ((modMask .|. controlMask,               xK_Up), sendMessage $ ExpandTowards U)
, ((modMask .|. controlMask .|. shiftMask, xK_Up), sendMessage $ ShrinkFrom U)
, ((modMask,                               xK_r), sendMessage BSP.Rotate)
, ((modMask,                               xK_s), sendMessage BSP.Swap)

Because of the missing comma on the first line, I use visual-block mode to do the alignment, ignoring the leading commas. Here's the keys I used, my cursor started at the beginning of the code block: f(<C-v>9j$ga,.

This is what I end up with after doing that:

  ((modMask .|. controlMask,               xK_Right), sendMessage $ ExpandTowards R)
, ((modMask .|. controlMask .|. shiftMask,  xK_Right), sendMessage $ ShrinkFrom R)
, ((modMask .|. controlMask,               xK_Left), sendMessage $ ExpandTowards L)
, ((modMask .|. controlMask .|. shiftMask,  xK_Left), sendMessage $ ShrinkFrom L)
, ((modMask .|. controlMask,               xK_Down), sendMessage $ ExpandTowards D)
, ((modMask .|. controlMask .|. shiftMask,  xK_Down), sendMessage $ ShrinkFrom D)
, ((modMask .|. controlMask,               xK_Up), sendMessage $ ExpandTowards U)
, ((modMask .|. controlMask .|. shiftMask,  xK_Up), sendMessage $ ShrinkFrom U)
, ((modMask,                               xK_r), sendMessage BSP.Rotate)
, ((modMask,                               xK_s), sendMessage BSP.Swap)

As you can see, the values after the first , of my selection are not all aligned with each other as I hoped they would be.

It's worth mentioning it worked as expected when I added a comma to the first line that was missing one and used visual-line mode (V9jga2,). Adding the comma outside the selection did not affect how visual-block mode behaved.

I'm on the latest version of vim-easy-align and Neovim 0.4.3.