search

Home  >  Q&A  >  body text

How to use the current line as a parameter to execute a shell command in vim?

1 hello
2 world
3 me

For example, I am currently on the second line, how do I execute !echo world?

给我你的怀抱给我你的怀抱2774 days ago707

reply all(2)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 16:42:40

    :.w !command命令可以把当前行送到命令的标准输入,比如:.w !cat,当然这不满足你的需求,因为你要的是作为命令行参数,所以你可以这么用:
    :.w !xargs command
    Okay I know it looks ugly, but it works...

    reply
    0
  • PHPz

    PHPz2017-05-16 16:42:40

    :echo getline('.')

    reply
    0
  • Cancelreply