I'm editing HTML files. I use this keymap to launch firefox to preview the page:
map <F6> :update<CR>:silent !xdg-open %:p<CR>
But after this command, the Vim window becomes completely black. I need to scroll every line to make it appear again.
So I want to write a function to fresh the buffer. Here's what i did:
function! Refresh()
" code
set noconfirm
bufdo e!
set confirm
endfunction
nmap <F5> :call Refresh()<CR>
I got the idea from this post. But it doesn't work.
The screen of Vim can be refreshed or redrawn by pressing Ctrl+l . If that does not work, use the command :redraw .
Buffers in vim are the in-memory text of files. Your window is a viewport on a buffer. You can switch between open buffers, this is similar to tabs in other editors. Vim does have a concept of tabs too, but they are slightly different, read more about tabs in the Windows section.
Use CtrlL to redraw the screen. You can also use :redraw
.
Check the help on these.
How about adding a "redraw" do your function (which does the same as ctrl-L)
:redr[aw][!] Redraw the screen right now. When ! is included it is
cleared first.
Useful to update the screen halfway executing a script
or function. Also when halfway a mapping and
'lazyredraw' is set.
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