vim:keys: Respect 'foldopen' on remapped movements

Execute 'zv' depending on the existence of the equivalent movement type
in 'foldopen'.
This commit is contained in:
2023-05-12 12:02:56 +02:00
parent f18cc6f05a
commit 5f20d6d26f

View File

@@ -60,9 +60,9 @@ map <leader>st <Cmd>set spell!<CR>
map <leader>sc <Cmd>call CycleSpellLang()<CR> map <leader>sc <Cmd>call CycleSpellLang()<CR>
map <leader>ss :set spelllang= map <leader>ss :set spelllang=
" Jump through jump table but center " Jump through jump table but center while still respecting 'foldopen'
noremap <Tab> <Tab>zvzz noremap <expr> <Tab> '<Tab>' . (match(&fdo, 'mark') > -1 ? 'zv' : '') . 'zz'
noremap <C-O> <C-O>zvzz noremap <expr> <C-O> '<C-O>' . (match(&fdo, 'mark') > -1 ? 'zv' : '') . 'zz'
nmap <S-Tab> <C-O> nmap <S-Tab> <C-O>
" Terminal " Terminal
@@ -274,13 +274,13 @@ vnoremap > >gv
vnoremap < <gv vnoremap < <gv
vnoremap = =gv vnoremap = =gv
" Center search results " Center search results while still respecting 'foldopen'
" TODO: this hides the search result indicator (i.e. [5/10]) " TODO: this hides the search result indicator (i.e. [5/10])
noremap n nzvzz noremap <expr> n 'n'. (match(&fdo, 'search') > -1 ? 'zv' : '') .'zz'
noremap N Nzvzz noremap <expr> N 'N'. (match(&fdo, 'search') > -1 ? 'zv' : '') .'zz'
cnoremap <expr> <CR> "<CR>" . cnoremap <expr> <CR> "<CR>" .
\ (getcmdtype() == '/' \|\| getcmdtype() == '?' \ (getcmdtype() == '/' \|\| getcmdtype() == '?'
\ ? "zvzz" \ ? (match(&fdo, 'search') > -1 ? 'zv' : '') . "zz"
\ : "") \ : "")
" Switch to lower/upper case " Switch to lower/upper case