[nvim] add a few little tricks found in romainl's Gists

This commit is contained in:
Dmytro Meleshko 2021-06-04 17:36:33 +03:00
parent d466b3ce30
commit 173661a619
2 changed files with 14 additions and 0 deletions

View file

@ -142,6 +142,9 @@ set commentstring=//%s
xnoremap <M-L> zL
xnoremap <M-Right> zl
" Repeat the last edit n times, taken from <https://gist.github.com/romainl/db725db7babc84a9a6436180cedee188>
nnoremap . <Cmd>execute "normal!" repeat(".", v:count1)<CR>
" }}}

View file

@ -137,6 +137,17 @@ endif
nmap [l <Plug>(qf_loc_previous)
nmap ]l <Plug>(qf_loc_next)
let g:qf_mapping_ack_style = 1
" Based on <https://stackoverflow.com/a/1330556/12005228>, inspired by
" <https://gist.github.com/romainl/f7e2e506dc4d7827004e4994f1be2df6>.
" But apparently `vimgrep /pattern/ %` can be used instead?
function! s:CmdGlobal(pattern, bang)
let pattern = substitute(a:pattern, "/.*$", "", "")
let matches = []
execute "g" . (a:bang ? "!" : "") . "/" . pattern . "/call add(matches, expand(\"%\").\":\".line(\".\").\":\".col(\".\").\":\".getline(\".\"))"
cexpr matches
endfunction
command! -bang -nargs=1 Global call <SID>CmdGlobal(<q-args>, <bang>0)
" }}}