摘要:的分屏很好用,可以开多个窗口对照代码,但是分的屏多了,需要临时扩大某个窗口到最大,编辑代码,使用完成之后,又想要恢复原先已经设置好的布局,本身没有提供这样的功能,但是提供了实现这种功能的基础下面的代码就实现了这样的功能将下面的代码保存为放到
Vim 的分屏很好用,可以开多个窗口对照代码,但是分的屏多了,需要临时扩大某个窗口到最大,编辑代码,使用完成之后,又想要恢复原先已经设置好的布局,Vim本身没有提供这样的功能,但是提供了实现这种功能的基础, 下面的代码就实现了这样的功能. 将下面的代码保存为vimlayout.vim放到 Vim的plugin目录下, 设置自己喜欢的绑定键就可以了工作了. 此代码在 Vim 7.3中测试通过.
</>复制代码
if exists("g:vimlayoutloaded")
finish
else
let g:vimlayoutloaded=1
endif
function! HeightToSize(height)
let currwinno=winnr()
if winheight(currwinno)>a:height
while winheight(currwinno)>a:height
execute "normal -"
endwhile
elseif winheight(currwinno)+"
endwhile
endif
endfunction
function! WidthToSize(width)
let currwinno=winnr()
if winwidth(currwinno)>a:width
while winwidth(currwinno)>a:width
execute "normal <"
endwhile
elseif winwidth(currwinno)>"
endwhile
endif
endfunction
function! TweakWinSize(orgisize)
call HeightToSize(a:orgisize[0])
call WidthToSize(a:orgisize[1])
endfunction
function! RestoreWinLayout()
if exists("g:layout")
let winno=1
let orgiwinno=winnr()
for win in g:layout
execute "normal w"
let currwinno=winnr()
if currwinno!=1 && currwinno!=orgiwinno
call TweakWinSize(g:layout[currwinno-1])
endif
endfor
unlet g:layout
endif
endfunction
function! SaveWinLayout()
let wnumber=winnr("$")
let winlist=range(wnumber)
let winno=0
let layout=[]
for index in winlist
let winno+=1
let wininfo=[winheight(winno),winwidth(winno)]
call add(layout,wininfo)
endfor
let g:layout=layout
endfunction
function! ToggleMaxWin()
if exists("g:layout")
if winnr("$")==len(g:layout)
call RestoreWinLayout()
else
call SaveWinLayout()
execute "normal 200>"
execute "normal _"
call RestoreWinLayout()
endif
else
call SaveWinLayout()
execute "normal 200>"
execute "normal _"
endif
endfunction
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/24761.html
摘要:一个项目文件多起来时,左边的文件树菜单是必要的。即使有相关的方法控制这些,只是作为一个文件菜单来说,这也太麻烦了。刷新正常下是不会自动刷新的,文件删除了,多了都不会自动显示。 一个项目文件多起来时,左边的文件树菜单是必要的。 参考:常用文件树快捷键所有命令及推荐键盘映射:官方 showImg(https://segmentfault.com/img/remote/14600000177...
阅读 2025·2021-11-11 16:55
阅读 2290·2021-10-08 10:13
阅读 860·2019-08-30 11:01
阅读 2272·2019-08-29 13:19
阅读 3362·2019-08-28 18:18
阅读 2690·2019-08-26 13:26
阅读 648·2019-08-26 11:40
阅读 1956·2019-08-23 17:17