2

I have setup my Vim Help to appear as a listed buffer for my ease of quick access and return to same page. The problem I face is that every time I jump around in Vim Help page using Ctrl-] a new Vim-Help-page-buffer is created, which is not what I want.

Is there a way to disable Vim from creating a new buffer every time I jump to a hyperlinked page within Vim Help pages?

Or else perhaps, is it possible to have the opening of a Vim-Help-hyperlinked-page to automatically trigger the deletion of the previous Vim-Help buffer? How could this be scripted?

  • 2
    It may be easier to let the help buffer unlisted, and use :ls! and :buffer <number> to jump to an existing help buffer instead. – VanLaser Oct 6 '15 at 13:39
  • Thanks, but choose not this way bec. want to have help listed. – Annis Monadjem Oct 7 '15 at 1:18
4

Well, I decided to answer my own question:

autocmd BufEnter,BufWinEnter * if &filetype=='help' 
        \| let w:bufnuc = bufnr("%")
        \| let w:bufnua = bufnr("#")
        \| if w:bufnua > 0
            \| execute "buffer " . w:bufnua
                \| if &filetype=='help' 
                    \| if w:bufnua != w:bufnuc
                        \| set nobuflisted
                    \| endif
                \| endif 
            \| execute "buffer " . w:bufnuc
        \| endif
    \| endif

It works as per spec's above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.