From aa1ba68ea0ccdffce778170496ff23fe1796cc28 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 30 Nov 2014 02:01:52 +0900 Subject: [PATCH] Retain cursor position after (EasyAlign) in visual mode --- autoload/easy_align.vim | 3 +++ test/interactive.vader | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/autoload/easy_align.vim b/autoload/easy_align.vim index 974fcc9..22dab26 100644 --- a/autoload/easy_align.vim +++ b/autoload/easy_align.vim @@ -778,6 +778,9 @@ function! s:interactive(range, modes, n, d, opts, rules, vis, bvis) if has_key(a:rules, ch) let d = ch if !s:live + if a:vis + execute "normal! gv\" + endif break endif else diff --git a/test/interactive.vader b/test/interactive.vader index d0301ce..6d4eb92 100644 --- a/test/interactive.vader +++ b/test/interactive.vader @@ -19,6 +19,17 @@ Expect: 111 22 333 444 55555 6666 7 88888 1111 2 33 444 555 66 777 8 +Do (left-align / cursor position retained): + vGww + \ + *\D + +Expect: + 1 22222 33 444 555 6666 7 888 + 11 222 3333 4 55 6666 77 888 + 111 22 333 444 55555 6666 7 88888 + 1111 2 + Do (left-align using operator map): \Aip*\ @@ -1663,7 +1674,7 @@ Do (Blockwise-visual-operator is also repeatable): f1 4j \: - 7G + 7G0 fa .