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]


This was easy.

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

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.