New answers tagged

-1

Thanks to @B Layers and @Matts answers, I've written this function which serves my purposes perfectly. I'm sharing it here for future reference, if anyone needs the same functionality. " Function to pipe output of vim command to external command. " The 'trim' argument determines whether the vim command " output will be trimmed before piping it to the ...


3

I'm not aware of any builtin, compact functionality that let's you filter the output of any vim command through any external command. With a little one-time scripting, though, you could get something like this... :MyFilt g/http/ | wc -l To start, put this in your vimrc... func! MyFilt(cmd) let parts = split(a:cmd, '|') let vimcmd = trim(parts[0]) ...


1

You can use :%s/pattern/gn The n tells it to count the g to count every occurrence.


3

but I don't have the option of piping the output to an external command Actually you do: echo system('wc -l', execute('g/http/')) However, note that execute() prepends a newline to the resulting string, while not appending a newline after it. Hence the result of wc -l remains the same, but it could matter under different circumstances.


Top 50 recent answers are included