aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2020-09-28 01:50:14 +0900
committernsfisis <nsfisis@gmail.com>2020-09-28 01:50:14 +0900
commit58920da73489a5a4da37d4082aee4b762983c402 (patch)
tree1dc13427926ae1d9e90c46f5593906163f98c56d
parent7b2324d80fb6bb3606e4f27229dd91133f53805f (diff)
downloaddotfiles-58920da73489a5a4da37d4082aee4b762983c402.tar.gz
dotfiles-58920da73489a5a4da37d4082aee4b762983c402.tar.zst
dotfiles-58920da73489a5a4da37d4082aee4b762983c402.zip
Update .vimrc: simplify :Reverse
-rw-r--r--.vimrc11
1 files 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<bang> <args>
-" 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 <SID>reverse_lines(<line1>, <line2>)
+ \ keeppatterns <line1>,<line2>g/^/m<line1>-1