Skip to main content
4 of 6
Overexplanation deleted

How can I chain multiple commands in one Leader command?

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 leader entry copies into system clipboard the text following "source: "; the second leader entry copies the currently cursored line into system clipboard. I use a clipboard manager thus I prefer to copy multiple items (separately) from a text file into clipboard.

How do I combine them into a single leader entry?

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:

what parcellite should show