72

The top window is called the preview window. So any of <c-w>z, <c-w><c-z> or :pc[lose][!] should work. The below is the help for :help :pclose CTRL-W z CTRL-W_z CTRL-W CTRL-Z CTRL-W_CTRL-Z :pc :pclose :pc[lose][!] Close any "Preview" window currently open. When the 'hidden' option is set, or when the buffer ...


31

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:SuperTabClosePreviewOnPopupClose = 1 YouCompleteMe let g:ycm_autoclose_preview_window_after_insertion = 1 let g:ycm_autoclose_preview_window_after_completion = 1 If the second ...


6

: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 about overwriting if writing wasn't involved. Also, note the message from a successful saveas command: "bar" [New] 364L, 1060C written


5

Your function returns nothing, but you call it expecting the buffer number. This should work: function! ScratchBuffer() vnew setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile return bufnr('%') endfunction


4

It's called "preview window" and you can read all about it in :help preview-window. The 'previewheight' option should be what you are looking for.


4

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 pumvisible() == 0 | pclose | endif The downside is that you won't be able to focus the scratch window, so no scrolling. But for quick lookups it's the most ...


4

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* *E445* CTRL-W CTRL-O *CTRL-W_CTRL-O* *:on* *:only* Make the current window the only one on the screen. All other windows are closed. ...


3

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 leading : is also redundant. Don't use " with :set, :h :quote is used to comment, everything after it is ignored. autocmd should always be created inside :h :augroup ....


2

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 buffer nofile buffer which is not related to a file and will not be written See :help special-buffers for more background on this and ...


1

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! showInPreview(name, fileType, lines) let l:command = "silent! pedit! +setlocal\\ " . \ "buftype=nofile\\ nobuflisted\\ " . \ "...


1

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/ file: function Scratch() setlocal noswapfile setlocal buftype=nofile setlocal bufhidden=hide endfunction And then call vim as vim -c 'call Scratch()', ...


1

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! ScratchBuffer() abort if bufname() == '' setl buftype=nofile setl bufhidden=hide setl noswapfile endif endfunc augroup vim_start | ...


1

Create a function, and then call said function from console when opening vim with the -c flag?


1

That should be enough: augroup scratch_write | au! autocmd BufWrite * \ if &bt ==# 'nofile' && (empty(bufname()) || bufname() ==# '-stdin-') | \ set nomodified \ TurnOffScratchBuffer | \ silent file <afile> | \ endif augroup end Also don't use quote inside :set and add :h command-bar ...


1

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. bufhidden=hide hides the buffer, when its windows is closed. Vim discards the content in the buffer on exit without warning. If you like to clear it before, you ...


1

: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, when vim is exited. If you would like to know more: :h special-buffers :h buftype


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