0

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.

Community
  • 1
  • 1
Mert Nuhoglu
  • 9,695
  • 16
  • 79
  • 117

1 Answers1

1

remove those :, try this line:

command! Getlinks let @a=""|%s/something/\=setreg('A', submatch(0), 'l')/g|%d _|pu a|0d _
Kent
  • 189,393
  • 32
  • 233
  • 301