junegunn / vim-easy-align

:sunflower: A Vim alignment plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cant' align a paragraph, when the last visual selection is a block from the latter.

lacygoill opened this issue · comments

If I have a paragraph such as:

hello foo world bye all
hello world foo bye all
hello world bye foo all

And I visually select the block of text at the end of it, containing the 3 words all, then escape to go back in normal mode, and try to align the text inside the paragraph using the regular expression foo, the plugin doesn't align anything. To make it work, I have to visually select the whole paragraph, or anything outside of it and go back to normal mode. Then, gaip C-x foo Enter produces the expected result:

hello           foo world bye all
hello world     foo bye all
hello world bye foo all

I think the problem comes from the fact that the plugin reselects the last visual selection in this particular case, even though the operator (mapped to ga in my case) is invoked from normal mode, not from visual mode. And since the last visual selection is not the whole paragraph, and doesn't contain foo, the plugin doesn't align anything.

I can reproduce by starting Vim like this:

vim -Nu /tmp/vimrc.vim

… and with the following minimal vimrc:

set rtp+=~/.vim/plugged/vim-easy-align/
nmap ga <Plug>(EasyAlign)

In case it helps, I uploaded a gif.

Thank you for your plugin.

Thanks, should be fixed now.