Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a "tips" popup in vim

Tags:

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?

like image 996
ae. Avatar asked Jan 25 '11 01:01

ae.


1 Answers

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>
like image 153
evan Avatar answered Nov 13 '22 15:11

evan