成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

Vim窗口布局保存插件

cnio / 2307人閱讀

摘要:的分屏很好用,可以開多個(gè)窗口對(duì)照代碼,但是分的屏多了,需要臨時(shí)擴(kuò)大某個(gè)窗口到最大,編輯代碼,使用完成之后,又想要恢復(fù)原先已經(jīng)設(shè)置好的布局,本身沒有提供這樣的功能,但是提供了實(shí)現(xiàn)這種功能的基礎(chǔ)下面的代碼就實(shí)現(xiàn)了這樣的功能將下面的代碼保存為放到

Vim 的分屏很好用,可以開多個(gè)窗口對(duì)照代碼,但是分的屏多了,需要臨時(shí)擴(kuò)大某個(gè)窗口到最大,編輯代碼,使用完成之后,又想要恢復(fù)原先已經(jīng)設(shè)置好的布局,Vim本身沒有提供這樣的功能,但是提供了實(shí)現(xiàn)這種功能的基礎(chǔ), 下面的代碼就實(shí)現(xiàn)了這樣的功能. 將下面的代碼保存為vimlayout.vim放到 Vim的plugin目錄下, 設(shè)置自己喜歡的綁定鍵就可以了工作了. 此代碼在 Vim 7.3中測(cè)試通過(guò).

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

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/24761.html

相關(guān)文章

  • tmux的超絕便利

    摘要:服務(wù)器的任務(wù)不間斷運(yùn)行,就是利用了的特性。超絕常用操作快捷鍵參考。我的配置如下基礎(chǔ)設(shè)置前綴綁定啟用鼠標(biāo)選中窗口將快捷鍵設(shè)置為模式 服務(wù)器的任務(wù)不間斷運(yùn)行,就是利用了tmux的特性。就是說(shuō),一般ssh是斷開就會(huì)停止所有之前連接ssh期間運(yùn)行的所有processes,而tmux的核心業(yè)務(wù)不在于把屏幕分成幾塊好看,而是它能保存session!而且還能多端實(shí)時(shí)直播session! 了解tmux...

    dunizb 評(píng)論0 收藏0
  • Vim的NerdTree插件

    摘要:一個(gè)項(xiàng)目文件多起來(lái)時(shí),左邊的文件樹菜單是必要的。即使有相關(guān)的方法控制這些,只是作為一個(gè)文件菜單來(lái)說(shuō),這也太麻煩了。刷新正常下是不會(huì)自動(dòng)刷新的,文件刪除了,多了都不會(huì)自動(dòng)顯示。 一個(gè)項(xiàng)目文件多起來(lái)時(shí),左邊的文件樹菜單是必要的。 參考:常用文件樹快捷鍵所有命令及推薦鍵盤映射:官方 showImg(https://segmentfault.com/img/remote/14600000177...

    Mike617 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<