dhruvasagar / vim-prosession

Handle vim sessions like a pro
254 stars 22 forks source link

Use %bwipe to remove current buffers #48

Closed blueyed closed 6 years ago

blueyed commented 6 years ago

Also removes the noautocmd, so that plugins can handle removal of buffers properly.

dhruvasagar commented 6 years ago

The noautocmd was to ensure this happens swiftly, with autocmds this may become time consuming

dhruvasagar commented 6 years ago

Also, :%bw is not right, it needs to be something like exec '1,'.bufnr('$').'bwipe'

Reason being :% is a special range that represents the start - end of the current files lines, which has no correlation with the number of buffers loaded within vim.

blueyed commented 6 years ago

% is used with buffer commands to mean "all buffers". Please see :h :bw, which mentions this:

:%bwipeout " wipe out all buffers

The noautocmd was to ensure this happens swiftly, with autocmds this may become time consuming

Correctness should be preferred over speed - Neomake uses BufWipeOut for example to clean caches etc.

I've tested :%b with 1000 buffers (:for i in range(1000) | exe 'badd '.i | endfor), and it took ~1s with my rather huge config (using a lot of plugins).

With nvim -u NORC creating 10000 buffers takes ~5s, and wiping them less than 1s.

So speed/performance is not really an issue here.

dhruvasagar commented 6 years ago

Thanks, looks like I missed the change for :%bw good to know.