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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With