开发者

How do I create a "tips" popup in vim

I have a few tips I am trying to remember in VIM. What would be cool is if I could get these to open in a horizontal split at the top of the current window with a keystroke (say F4), then hide again (toggle) when hitting F4 again.

So how can I get a text file to open in a (smallish) split above my开发者_如何学编程 current window with a toggle keypress?

Perhaps there is a plugin I don't know about that does this?


This should do it. It will work in normal mode only so it doesn't interfere with actually typing an <F4>. Add it to your .vimrc. Loads the file specified into a preview window. In this case it is ~/vimtips.txt

View this link for more on the preview window. You can set things like the size of the preview window with some other options: http://vimdoc.sourceforge.net/htmldoc/windows.html#preview-window

let g:MyVimTips="off"
function! ToggleVimTips()
  if g:MyVimTips == "on"
    let g:MyVimTips="off"
    pclose
  else
    let g:MyVimTips="on"
    pedit ~/vimtips.txt
  endif
endfunction

nnoremap <F4> :call ToggleVimTips()<CR>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜