| Some other things I do: Invoke terminals on directories (instead of netrw). So, I can e.g. sp. to split to a new terminal. function! Isdir(dir) abort
return !empty(a:dir) && (isdirectory(a:dir) ||
\ (!empty($SYSTEMDRIVE) && isdirectory('/'..tolower($SYSTEMDRIVE[0])..a:dir)))
endfunction
augroup terminal-explorer
au!
au VimEnter * sil! au! FileExplorer *
au VimEnter * sil! au! Network *
au VimEnter * sil! au! AuNetrwEvent *
" au FileType netrw cd % | bw | exe 'terminal ++curwin'
au BufEnter * if &filetype != 'netrw' && Isdir(expand('%')) | lcd % | exe bufnr("%") ..'bufdo terminal ++curwin' | endif
augroup end
Make <C-@>m close windows instead: noremap <C-@>m <C-w>c
noremap! <C-@>m <Esc><C-w>c
tnoremap <C-@>m <C-@>c
Make <C-@>p find the next window if there is no previous window: noremap <expr> <silent> <C-@>p ':<C-u>wincmd p <Bar> if win_getid () == ' .. win_getid () .. ' <Bar> wincmd w <Bar> endif <CR>'
noremap! <expr> <silent> <C-@>p '<Esc>:<C-u>wincmd p <Bar> if win_getid () == ' .. win_getid () .. ' <Bar> wincmd w <Bar> endif <CR>'
tnoremap <expr> <silent> <C-@>p '<C-@>:<C-u>wincmd p <Bar> if win_getid () == ' .. win_getid () .. ' <Bar> wincmd w <Bar> endif <CR>'
Use <C-@>~. to detach the GNU screen that my vim is running in (I put my vim in a screen with `unbindall` i.e. I use screen merely for keeping my vim alive) (<C-@>~. is in analogy to the SSH quit keybinding <CR>~.). noremap <expr> <silent> <C-@>~. ':<C-u>silent !screen -X detach<CR>'
noremap! <expr> <silent> <C-@>~. '<C-@>:<C-u>silent !screen -X detach<CR>'
tnoremap <expr> <silent> <C-@>~. '<C-@>:<C-u>silent !screen -X detach<CR>'
With gf and gF, opening files just from a terminal grep is practically more convenient than vim's :grep. For gf in a new tab: map <silent> <C-@><C-f> :<C-u>tab split<CR>gf
With terminal multiplexing in vim, you start getting a lot of buffers. You can consider getting a custom tabline. Other tab management features become more important too. You might expect [count]gt to behave just like gt for [count] times: nnoremap <expr> gt '@_' .. ((v:count1 + (tabpagenr () - 1)) % (tabpagenr('$') ) + 1) .. 'gt'
For ease of moving to the last tab: nnoremap <expr> g<C-t> '@_' .. (((v:count == 0) ? tabpagenr ('$') : v:count)) .. 'gt'
To consistently access the gt family of bindings regardless of mode: map <C-@>gt gt
map <C-@>gT gT
map <C-@>g<C-t> g<C-t>
map! <C-@>gt <Esc>gt
map! <C-@>gT <Esc>gT
map! <C-@>g<C-t> <Esc>g<C-t>
tmap <C-@>gt <C-@>Ngt
tmap <C-@>gT <C-@>NgT
tmap <C-@>g<C-t> <C-@>Ng<C-t>
When you use <C-w>T a lot to move your windows in to new tabs, you might sometimes want to move them to the previous tab instead of the next one: nnoremap <silent> <C-@><C-t> <C-w>T
nnoremap <silent> <C-@>T <C-w>T:<C-u>tabm -1<CR>
To access these two in any mode consistently: map! <C-@><C-t> <Esc><C-@><C-t>
map! <C-@>T <Esc><C-@>T
tmap <C-@><C-t> <C-@>N<C-@><C-t>
tmap <C-@>T <C-@>N<C-@>T
Analogously to gt and gT, sometimes you may want to move your tabs around, or split them: function! SSStabmadjust(tabmnum)
if a:tabmnum < tabpagenr ()
return a:tabmnum - 1
else
return a:tabmnum
endif
endfunction
noremap <silent> <C-@><C-g>s :<C-u>tab split<CR>
noremap <expr> <silent> <C-@><C-g>t '@_:<C-u>' .. SSStabmadjust ((v:count1 + (tabpagenr () - 1 )) % (tabpagenr('$') ) + 1) .. 'tabm<CR>'
noremap <expr> <silent> <C-@><C-g>T '@_:<C-u>' .. SSStabmadjust (((- v:count1 + (tabpagenr () - 1 )) % (tabpagenr('$') ) + tabpagenr('$') ) % (tabpagenr('$') ) + 1) .. 'tabm<CR>'
noremap <expr> <silent> <C-@><C-g><C-t> ':<C-u>' .. ((v:count == 0) ? "" : SSStabmadjust ((v:count % (tabpagenr ('$') )) )) .. 'tabm<CR>'
map! <C-@><C-g>s <Esc><C-@><C-g>s
map! <C-@><C-g>t <Esc><C-@><C-g>t
map! <C-@><C-g>T <Esc><C-@><C-g>T
map! <C-@><C-g><C-t> <Esc><C-@><C-g><C-t>
tmap <C-@><C-g>s <C-@>N<C-@><C-g>s
tmap <C-@><C-g>t <C-@>N<C-@><C-g>t
tmap <C-@><C-g>T <C-@>N<C-@><C-g>T
tmap <C-@><C-g><C-t> <C-@>N<C-@><C-g><C-t>
|