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* *...
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 ...
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 ...
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 ...
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 ...
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! ...
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
...
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/ ...
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! ...
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?
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
...
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.
...
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, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
scratch-buffer × 10buffers × 5
previewwindow × 2
vimrc × 1
vimscript × 1
autocmd × 1
functions × 1
save × 1
vimscript-python × 1
startup × 1
plugin-fugitive × 1
echo × 1
hidden-buffers × 1
security × 1