Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External Filter support #3154

Closed
reviewher opened this issue Oct 20, 2018 · 2 comments · Fixed by #4989
Closed

External Filter support #3154

reviewher opened this issue Oct 20, 2018 · 2 comments · Fixed by #4989

Comments

@reviewher
Copy link

Is your feature request related to a problem? Please describe.
:{range}! is a common idiom for running an external filter like awk or jq for processing data. Currently all commands fail with "Not an editor command"

Describe the solution you'd like

  • :! foo would execute foo and pipe the result to the Output tab
  • :<range>!foo would execute foo, using the specified lines as stdin, and replacing those lines in the file with the output from the command. stderr would be piped to Output.

Describe alternatives you've considered
An alternative is to run a parallel instance of vim and perform those operations on the vim instance, relying on the fact that both vscode and vim will detect if the file changed, but that's not exactly a great solution

Additional context
See :help filter for more info on the family of commands

@jseely
Copy link

jseely commented Feb 7, 2019

I would love to see this feature added, one of the most powerful features in Vim for regular use!

@noonien
Copy link

noonien commented Dec 18, 2019

I also use this feature all the time in vim, to run all sorts of command-line filters on the code, grep, sed, awk, jq, small one-line perl scripts and even to upload parts of code to pastebins.

This extension helped me give vscode a chance, but this feature is a must-have IMHO, along with :w !{command}

J-Fields pushed a commit that referenced this issue Jul 6, 2020
This PR ports the :!{cmd} bang command from Vim, allowing external shell commands to be run directly from Vim's command mode.

Key features:
- :!{cmd} executes the shell command
- :{range}!{cmd} executes the shell command, pipes the line range to stdin, and replaces the line range with the output from stdout and stderr
- Embedded bangs are replaced with the previous bang command (e.g. :!dir => :!echo ! will execute echo dir)
- Cross-platform, supports Unix and Windows shells

Fixes #3154, fixes #3136, fixes #3069, fixes #4920
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants