These two mappings work separately:
nnoremap <leader>zs :let @+=substitute(substitute(join(filter(getline(1,'$'),'v:val=~"^source:"'),"\n"),'^\(source:\s*\)\(.*\)$','\2',''),'^\s*\(.*\)$','\1','')<CR><ESC>
nnoremap <leader>zd :let @+=getline('.')<CR>
Note on what the codes need to accomplish: the first mapping copies into system clipboard the text following "source: "; the second mapping copies the currently cursored line into system clipboard. I use a clipboard manager (Parcellite) thus I prefer to copy multiple items (separately) from a text file into clipboard.
How do I combine them into a single mapping?
I've tried following this answer to produce:
nnoremap <leader>zs :let @+=substitute(substitute(join(filter(getline(1,'$'),'v:val=~"^source:"'),"\n"),'^\(source:\s*\)\(.*\)$','\2',''),'^\s*\(.*\)$','\1','') \| let @+=getline('.')<CR>
but this doesn't work. What could I be doing wrong?
[UPDATE]
To illustrate, here is a sample text showing [*] where the cursor is currently in:
Her research also shows about 14% of adults are clinically addicted to food, predominantly ultraprocessed foods with higher levels of sugar, salt, fat and additives.
For comparison, 10.5% of Americans age 12 or older were diagnosed with alcohol use disorder in 2022, according to the National Survey on Drug Use and Health. [*]
While many people addicted to food will say that their symptoms began to worsen significantly in adolescence, some recall a childhood focused on ultraprocessed food.
source: https://edition.cnn.com/2024/06/27/health/child-addiction-ultraprocessed-foods-wellness/index.html
After pressing <leader>zs
in vim, parcellite should show this when accessed:
let @+=
will by pass the clipboard manager. Can tell us which is the clipboard manager that you are using such that we can try to reproduce your problem?let @+=
apparently does not bypass parcellite since the two codes, run separately, achieves the stacking that I intend. I hope this also clarifies @D. Ben Knoble's comment.:sleep 500m
between the two processes prove otherwise. Either that or there is a problem with how is inserted the sleep.