I intend to use this to optionally share the search buffer between different Vim instances. I'll have a file on the filesystem that contains the content. So it means I need to set the search register with the contents of a file.

I'm hoping there's a clean Vimscript way to do this. It's ok if it uses python or any other language integration too.

I think this is how to edit the register: let @/ = [whatever]

  • 2
    For the record someone made a plugins which seems to be doing what you want: github.com/dahu/VimSharedSearch I've never tried it so I don't know what it's worth.
    – statox
    Aug 2, 2017 at 7:13

1 Answer 1


This was easy.

nnoremap <silent> <Leader>n :let @/ = join(readfile(glob("~/.vim/.search")), "\n")<CR>

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.