Skip to main content
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
  • 25.1k
5 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.6k
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
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,358
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

Show lines in scratch buffer in preview window

I would do: function! LoadPreviewWindow(bufnr) try wincmd P catch silent! pedit! wincmd P endtry execute 'b' . a:bufnr wincmd p endfunction " show in preview window ...
Vivian De Smedt'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
  • 27.7k
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.9k
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
  • 21.6k
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
  • 957
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
  • 957

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