How can I filter the contents of a register in vim?

I want to filter the contents of the register (in my case, the clipboard case "+) through an external command before pasting it into the clipboard.

There should be a solution along the lines of VIM: keep the output of the external command in register , but I just can not understand it from.

+3
source share
2 answers

system () is the way to go. :h system().

You can use the old way (the one that gives you full control, since you can direct and redirect as many times as you like):

:let res = system("echo ".shellescape(@+)." | the-filter-command")
:put=res

( ). , , vim :

:let res = system(the-filter-command, @+)
:put=res

, :

:new
:put=@+
:%!the-filter-command
:%d +
:bd
:put=@+

: Vim , :sort, uniq ( ),...

+5
:let @a = system("ls -l " . shellescape(@+))

, .

+1

Source: https://habr.com/ru/post/1733015/


All Articles