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

Support "bang" operations on selected code blocks #3136

Closed
ijstokes opened this issue Oct 14, 2018 · 9 comments · Fixed by #4989
Closed

Support "bang" operations on selected code blocks #3136

ijstokes opened this issue Oct 14, 2018 · 9 comments · Fixed by #4989

Comments

@ijstokes
Copy link

Is your feature request related to a problem? Please describe.
With standard Vim I regularly use block-select to pick a group of lines and then pass them to a piped Unix filter, e.g. :'<,'>!sort|uniq. As best I can tell, this isn't possible with the VSC Vim plugin today.

Describe the solution you'd like
Support "bang" (!) operations when in command mode

Describe alternatives you've considered
I don't know another way to do this. Right now if it is important enough I cut and paste the content into an empty document in Vim, do the operation there, then cut and paste the content back in to Visual Studio Code.

@beaugunderson
Copy link

Hmm... Shift-V to select lines, then :!sort or :!tac used to work prior to 1.31.0 and now does not work for me. It now just refreshes all the text on screen.

@beaugunderson
Copy link

(It could also have broken in the recent VSCodeVim release; I'm not sure if it was VSCode upgrade that broke it)

@beaugunderson
Copy link

I uninstalled some extensions and reloaded and this works again... Could have been a conflict or it could have been that the behavior is just finnicky. Will comment again if it breaks again and a reload fixes it.

@sjackman
Copy link

Thank you for VSCodeVim! It's fantastic.

:r!seq 10 works for me!
!!date does not work for me.
:.!date does not work for me.
:'<,'>!sort does not work for me (selecting a block with V and then !sort)

Should these work? Please consider this post a feature request if these are not currently implemented.

VSCodeVim 1.10.2
Visual Studio Code 1.38.1

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
@sjackman
Copy link

@tagniam Thank you very much for PR #4989!

:r!date always worked for me!
:.!date works for me after PR #4989!
V:!sort works for me after PR #4989!
V!sort does not work for me. (selecting a block with V and then !sort without first :)
!!date does not work for me.

@tagniam
Copy link
Contributor

tagniam commented Jul 17, 2020

Hey @sjackman, I separated the filter operators like V! and !! into a separate PR, which is pretty much done now. I'll be submitting it asap. Thanks!

@sjackman
Copy link

Thank you very much, JR!

@catskul
Copy link

catskul commented Oct 1, 2021

AFAICT, this is either broken again, or never completely fixed. I can find no working way to select and sort text using !sort

I have a recollection of it previously working, so it may have broken recently, but I don't trust my memory here as I jump back and forth between vscode and neovim regularly.

@tagniam
Copy link
Contributor

tagniam commented Oct 2, 2021

Hey @catskul, yeah I think this was sorta broken by a recent commit, but I have a fix for it and I'll put up a PR soon.

In the meantime you can use sort without the bang to sort a selection.

J-Fields pushed a commit that referenced this issue Oct 3, 2021
Line range tests didn't catch the recent regression
where selection ranges were ignored in the bang command.

Fixes #3136 (again)
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.

5 participants