Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
35 votes

Is there an easy way to close a scratch buffer/preview window?

For my specific case, the preview window was opened by plugins. So, I used plugin configuration to automatically close these windows. Supertab As suggested by Alex Kroll: let g:...
muru's user avatar
  • 24.9k
6 votes

Is there an easy way to close a scratch buffer/preview window?

another nice option, which is relevant also in other cases, is using :only to close all other windows, including the preview: :on[ly][!] :{count}on[ly][!] CTRL-W o *CTRL-W_o* *...
Beka's user avatar
  • 295
6 votes
Accepted

What is the difference between :file and :saveas

:saveas does write to files, after all the help says: "Save the current buffer under the name {file}". Note also how it says that ! is needed to overwrite an existing file. You wouldn't need to talk ...
muru's user avatar
  • 24.9k
4 votes

Is there an easy way to close a scratch buffer/preview window?

Another option that automatically closes the preview window and that should work with multiple completion plugins was suggested by deoplete's author in an issue: autocmd InsertLeave,CompleteDone * if ...
lleaff's user avatar
  • 141
4 votes
Accepted

how to create a buffer like a fugitive temporary buffer

You can create a buffer like this with the 'buftype' option: :set buftype=nofile As :help 'buftype' explains: The value of this option specifies the type of a buffer: <empty> normal ...
Rich's user avatar
  • 32.1k
3 votes
Accepted

Saving a scratch buffer

Some notes You don't need both StdinReadPre and StdinReadPost, one is enough. TurnOnScratchBuffer and TurnOffScratchBuffer are valid command, they can be executed directly without execute, the ...
dedowsdi's user avatar
  • 6,268
2 votes
Accepted

How to create Preview window to display a string?

After seven hours of fiddling with the documentation and searching, I was able to write a function that takes a filetype, an array of strings and show a dummy buffer based on that. function! ...
Sri Harsha Chilakapati's user avatar
1 vote
Accepted

Is there a shorter way to start vim with scratch buffer?

A sh/bash answer (even though the site is vi) vtmp () { vim +noswapfile +"setlocal buftype=nofile" +"setlocal bufhidden=hide" "$@" } A vim answer: Put this function in your vimrc or in a plugin/ ...
D. Ben Knoble's user avatar
  • 26.4k
1 vote

Is there a shorter way to start vim with scratch buffer?

There might be better approaches (e.g. alias to vim +noswapfile +"set buftype=nofile" +"set bufhidden=hide") but you can also use VimEnter autocommand to set up initial things, for example: func! ...
Maxim Kim's user avatar
  • 13.5k
1 vote

Is there a shorter way to start vim with scratch buffer?

Create a function, and then call said function from console when opening vim with the -c flag?
110100100's user avatar
1 vote

Saving a scratch buffer

That should be enough: augroup scratch_write | au! autocmd BufWrite * \ if &bt ==# 'nofile' && (empty(bufname()) || bufname() ==# '-stdin-') | \ set nomodified ...
Matt's user avatar
  • 20.8k
1 vote

How to create a new 'secure scratchpad' buffer?

In this case i would :new :setlocal buftype=nofile :setlocal bufhidden=hide :setlocal noswapfile buftype=nofile does not associate the buffer with a file. noswapfile does not create a swapfile. ...
mike's user avatar
  • 949
1 vote

What is the difference between :file and :saveas

:saveas is not going to work in a scratch buffer. A scratch buffer is a temporary buffer, that is not associated with a file and therefore cannot be saved. Instead they are discarded without warning, ...
mike's user avatar
  • 949

Only top scored, non community-wiki answers of a minimum length are eligible