I am trying to write a simple vim command that will get some texts and clean everything else.
The following Vim script does it:
:let @a=""|%s//\=setreg('A', submatch(0), 'l')/g|%d _|pu a|0d _
I put this script into a custom command:
command! Getlinks :let @a=""|:%s/something/\=setreg('A', submatch(0), 'l')/g|:%d _|:pu a|:0d _
When I run Getlinks
command, it removes everything but doesn't put the matched texts. But when I run the script's commands manually then it works as expected. Why doesn't it put the matched texts when used as Getlinks
command.