Closed mcandre closed 10 years ago
What does the command set hidden?
return when you run it (don't forget the question mark in the command)?
My suspicion is that it is not enabled for you. When it is, buffers can continue to exist even when they are not displayed (help 'hidden'
for more information). In particular here, the scratch window is configured by default to automatically hide as soon as it loses focus (think of it as only taking real estate when it is needed). When you next reopen it (either via the :Scratch
command or the gs
mapping), its contents will still be there.
The autohide behavior can be toggled off by setting the configuration variable g:scratch_autohide
to 0
.
And I would also guess that the hello.cpp
window isn't actually mislabeled, but that the screen just hasn't been redrawn. Try executing :redraw
and let me know if it doesn't fix it.
Thanks for taking the time to respond to each of my many requests :)
Yes, hidden?
was returning nohidden
. By adding set hidden
and let g:scratch_autohide = 0
to my .vimrc
, I was able to get the behaviour I wanted.
Glad I could help :).
I just switched the default for g:scratch_autohide
to depend on the value of 'hidden'
. It didn't make much sense otherwise.
Yay! That means less configuration in my .vimrc!
I'm new to Vim, so maybe I'm doing this wrong, but...
When I try to switch from the Scratch window to the window I was on, I get weird behavior.
vim hello.cpp
:Scratch
Ctrl+w Ctrl+w
Ctrl+w Ctrl+w
Step 4 does nothing, and step 3 does a strange thing: The scratch window visibly disappears, but the resulting hello.cpp window is mistakenly labelled "Scratch" [New File].
I come from Emacs, where the
*scratch*
buffer is builtin, designed to be more persistent (by default, open until Emacs quits) and it's natural for users to switch back and forth between scratch and the code file they're editing.Is there a way we can make Vim Scratch switch back and forth more naturally like in Emacs?