search

Home  >  Q&A  >  body text

When using `/` to search in vim, can different searches be performed in each buffer without affecting each other?

vim version: 7.4 huge version.

There will be multiple buffers in use, there will be multiple split windows in one tab, and there will be multiple tabs.

Can multiple buffers in a vim process be searched separately without affecting each other?

漂亮男人漂亮男人2856 days ago825

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 16:41:03

    Vim’s tab is just a container for display
    The only thing that really exists is buffer

    @Evian gave you suggestions on how to use the BufEnter/BufLeave event
    Then let me help you complete the code

    1

    2

    3

    4

    5

    6

    7

    <code>augroup SearchKeyword

        autocmd!

        autocmd BufEnter * let @/ = exists('b:keyword') ? b:keyword : ''

        autocmd BufLeave * let b:keyword = @/

    augroup END

     

    </code>

    • nohlsearchautocmd Invalid, deleted

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 16:41:03

    You can write your own plug-in.
    Logging @/ to a buffer-local variable (b:) on a BufLeave event and doing the opposite on a BufEnter event.

    by @evian

    reply
    0
  • Cancelreply