Toggle a blank screen in vim, to see through trans

2019-07-11 21:26发布

I work in Vim(not GVim, or MacVim etc), and I've taken use a non-opaque terminal, so I can see my background behind it(which is this movement cheat-sheet)

I'd like a way, to make the instance of vim a blank screen, then be able to re-draw it as it was before. Maybe I'm just failing at my web-searching, but I can't find anything towards this issue.

I'm more than grateful for anything, even just a link to some documentation method that can get me started down the rabbit hole.

2条回答
孤傲高冷的网名
2楼-- · 2019-07-11 21:39

I've achieved my Desired effect through bits and pieces, a related question, and help from @Ken and @Prince Goulash. Here's the functioning piece of vimscript that is in my .vimrc:

function! TabIsEmpty()
    " From Stackoverflow: http://stackoverflow.com/a/5026456/212307
    " Remember which window we're in at the moment
    let initial_win_num = winnr()

    let win_count = 0
    " Add the length of the file name on to count:
    " this will be 0 if there is no file name
    windo let win_count += len(expand('%'))

    " Go back to the initial window
    exe initial_win_num . "wincmd w"

    " Check count
    if win_count == 0
        " Tab page is empty
        return 1
    else
        return 0
    endif

endfunction
function! ToggleBlankTab()
    if TabIsEmpty() == 1
        tabc
    else
        tabe
    endif
endfunction
nnoremap <leader>m :call ToggleBlankTab()<cr>
查看更多
Viruses.
3楼-- · 2019-07-11 22:00

If you edit a new buffer (in a file that doesn't exist) you'll get a blank screen

:ed foo

When you're done you can just delete it

:bd
查看更多
登录 后发表回答