From 58920da73489a5a4da37d4082aee4b762983c402 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 28 Sep 2020 01:50:14 +0900 Subject: Update .vimrc: simplify :Reverse --- .vimrc | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.vimrc b/.vimrc index 3d293a9..9582c7b 100644 --- a/.vimrc +++ b/.vimrc @@ -1067,20 +1067,13 @@ command! -bang -bar -nargs=* \ make -" The current search pattern will not changed by :global in a user function. -" See :Reverse's comment below. -function! s:reverse_lines(from, to) abort - execute printf("%d,%dg/^/m%d", a:from, a:to, a:from - 1) -endfunction - " Reverse a selected range in line-wise. " Note: directly calling `g/^/m` will overwrite the current search pattern with " '^' and highlight it, which is not expected. -" :h autocmd-searchpat -" :h :nohlsearch +" :h :keeppatterns command! -bar -range=% \ Reverse - \ call reverse_lines(, ) + \ keeppatterns ,g/^/m-1 -- cgit v1.2.3-70-g09d2