aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.vimrc17
1 files changed, 17 insertions, 0 deletions
diff --git a/.vimrc b/.vimrc
index 1df1a4e..0934775 100644
--- a/.vimrc
+++ b/.vimrc
@@ -1074,6 +1074,8 @@ inoreabbrev tihs this
" Commands {{{1
+" Set 'makeprg' to `ninja` if `build.ninja` exists in the current working
+" directory. Then, execute :make command.
command! -bang -bar -nargs=*
\ Make
\ if filereadable('build.ninja') |
@@ -1082,6 +1084,21 @@ 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
+command! -bar -range=%
+ \ Reverse
+ \ call <SID>reverse_lines(<line1>, <line2>)
+