Skip to content

Instantly share code, notes, and snippets.

@paradigm
Last active April 13, 2020 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paradigm/14aa693d0e17c33b29f736df6a309f28 to your computer and use it in GitHub Desktop.
Save paradigm/14aa693d0e17c33b29f736df6a309f28 to your computer and use it in GitHub Desktop.
# use vim ex commands in a UNIX pipe
# e.g.:
# $ printf "foo\nbar\nbaz\n" | vp 'g/^b/d'
# foo
#
vp() {
vim - -u NONE -es '+1' "+$*" '+%print' '+:qa!' | tail -n +2
}
# use vim normal mode commands in a UNIX pipe
# e.g.:
# $ printf "foo\nbar\nbaz\n" | vn 'dd'
# bar
# baz
#
vn() {
vim - -u NONE -es '+1' "+normal $*" '+%print' '+:qa!' | tail -n +2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment