AnswerBun.com

keep contents of nofile buffer

My plugin creates new buffer, sets buffer type to nofile and fills it with text via job_start with out_io=buffer. Simplified code:

enew
setl bt=nofile
...
call job_start(cmd, {'out_io': 'buffer', 'out_buf': bufnr('%')})

Works fine, but when I switch to new buffer, and then return back, created buffer is empty. So, looks like vim doesn’t keep contents of nofile buffers.
Is there any way to keep nofile buffer contents for vim session?

Vi and Vim Asked by Igor Semenov on January 2, 2021

1 Answers

One Answer

You also need setl bufhidden=hide to prevent the buffer from getting unloaded when you switch to another buffer.

See also :help special-buffers, in particular the entry for "scratch" buffers.

Correct answer by filbranden on January 2, 2021

Add your own answers!

Related Questions

Text to vim-quickfix with navigation

1  Asked on December 30, 2021

   

add second column next to line number column

1  Asked on December 28, 2021 by cmosig

 

Append single-line register to many lines

1  Asked on December 26, 2021 by mat-m

   

termguicolors vs :terminal: incorrect colors being displayed

0  Asked on December 16, 2021 by henrique-barcelos

   

Unable to map ctrl-l

0  Asked on December 2, 2021

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved.