Skip to content

Commit 9610e7e

Browse files
committed
feat(vim): add hotkey to zoom windows in Vim/Neovim
Keybindins: <leader>z
1 parent e5779f7 commit 9610e7e

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

vim/vimrc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3537,6 +3537,31 @@ nnoremap Y y$
35373537
" :W 普通用户没有权限时使用 sudo 权限保存文件.
35383538
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
35393539

3540+
" n/N/*/# 搜索关键字后每次跳转都将目标显示在屏幕中间区域.
3541+
" Keep search pattern at the center of the screen.
3542+
nnoremap <silent> n nzz
3543+
nnoremap <silent> N Nzz
3544+
nnoremap <silent> * *zz
3545+
nnoremap <silent> # #zz
3546+
3547+
" ,z 当一个界面上有多个窗口时, 可以放大或还原当前所在的子窗口.
3548+
" Zoom windows.
3549+
" from: http://stackoverflow.com/questions/13194428/is-better-way-to-zoom-windows-in-vim-than-zoomwin
3550+
nnoremap <silent> <leader>z :ZoomToggle<CR>
3551+
3552+
function! s:ZoomToggle() abort
3553+
if exists('t:zoomed') && t:zoomed
3554+
execute t:zoom_winrestcmd
3555+
let t:zoomed = 0
3556+
else
3557+
let t:zoom_winrestcmd = winrestcmd()
3558+
resize
3559+
vertical resize
3560+
let t:zoomed = 1
3561+
endif
3562+
endfunction
3563+
command! ZoomToggle call s:ZoomToggle()
3564+
35403565
" }}
35413566

35423567
"""""" 其他配置 Other Settings {{
@@ -3648,6 +3673,12 @@ endif
36483673
" 出错时, 发出视觉提示, 通常是屏幕闪烁.
36493674
"set visualbell
36503675

3676+
" 关闭方向键, 强制用 hjkl.
3677+
"map <Left> <Nop>
3678+
"map <Right> <Nop>
3679+
"map <Up> <Nop>
3680+
"map <Down> <Nop>
3681+
36513682
" }}
36523683

36533684

0 commit comments

Comments
 (0)