Diff
1diff --git a/plugins/vim-interaction/README.md b/plugins/vim-interaction/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..65e678b519123d9460728a7ea593b4d3ce25a9fc
4--- /dev/null
5+++ b/plugins/vim-interaction/README.md
6@@ -0,0 +1,69 @@
7+# Vim Interaction #
8+
9+The plugin presents a function called `callvim` whose usage is:
10+
11+ usage: callvim [-b cmd] [-a cmd] [file ... fileN]
12+
13+ -b cmd Run this command in GVIM before editing the first file
14+ -a cmd Run this command in GVIM after editing the first file
15+ file The file to edit
16+ ... fileN The other files to add to the argslist
17+
18+## Rationale ##
19+
20+The idea for this script is to give you some decent interaction with a running
21+GVim session. Normally you'll be running around your filesystem doing any
22+number of amazing things and you'll need to load some files into GVim for
23+editing, inspecting, destruction, or other bits of mayhem. This script lets you
24+do that.
25+
26+## Aliases ##
27+
28+There are a few aliases presented as well:
29+
30+* `v` A shorthand for `callvim`
31+* `vvsp` Edits the passed in file but first makes a vertical split
32+* `vhsp` Edits the passed in file but first makes a horizontal split
33+
34+## Examples ##
35+
36+This will load `/tmp/myfile.scala` into the running GVim session:
37+
38+ > v /tmp/myfile.scala
39+
40+This will load it after first doing a vertical split:
41+
42+ > vvsp /tmp/myfile.scala
43+ or
44+ > v -b':vsp' /tmp/myfile.scala
45+
46+This will load it after doing a horizontal split, then moving to the bottom of
47+the file:
48+
49+ > vhsp -aG /tmp/myfile.scala
50+ or
51+ > v -b':sp' -aG /tmp/myfile.scala
52+
53+This will load the file and then copy the first line to the end (Why you would
54+ever want to do this... I dunno):
55+
56+ > v -a':1t$' /tmp/myfile.scala
57+
58+And this will load all of the `*.txt` files into the args list:
59+
60+ > v *.txt
61+
62+If you want to load files into areas that are already split, use one of the
63+aliases for that:
64+
65+ # Do a ':wincmd h' first
66+ > vh /tmp/myfile.scala
67+
68+ # Do a ':wincmd j' first
69+ > vj /tmp/myfile.scala
70+
71+ # Do a ':wincmd k' first
72+ > vk /tmp/myfile.scala
73+
74+ # Do a ':wincmd l' first
75+ > vl /tmp/myfile.scala
76diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh
77new file mode 100644
78index 0000000000000000000000000000000000000000..3f346dfc371c37049a3ef51b689b9b1aaf20ae2a
79--- /dev/null
80+++ b/plugins/vim-interaction/vim-interaction.plugin.zsh
81@@ -0,0 +1,67 @@
82+#
83+# See README.md
84+#
85+# Derek Wyatt (derek@{myfirstnamemylastname}.org
86+#
87+
88+function resolveFile
89+{
90+ if [ -f "$1" ]; then
91+ echo $(readlink -f "$1")
92+ else
93+ echo "$1"
94+ fi
95+}
96+
97+function callvim
98+{
99+ if [[ $# == 0 ]]; then
100+ cat <<EOH
101+usage: callvim [-b cmd] [-a cmd] [file ... fileN]
102+
103+ -b cmd Run this command in GVIM before editing the first file
104+ -a cmd Run this command in GVIM after editing the first file
105+ file The file to edit
106+ ... fileN The other files to add to the argslist
107+EOH
108+ return 0
109+ fi
110+
111+ local cmd=""
112+ local before=""
113+ local after=""
114+ while getopts ":b:a:" option
115+ do
116+ case $option in
117+ a) after="$OPTARG"
118+ ;;
119+ b) before="$OPTARG"
120+ ;;
121+ esac
122+ done
123+ shift $((OPTIND-1))
124+ if [[ ${after#:} != $after && ${after%<cr>} == $after ]]; then
125+ after="$after<cr>"
126+ fi
127+ if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then
128+ before="$before<cr>"
129+ fi
130+ local files=""
131+ for f in $@
132+ do
133+ files="$files $(resolveFile $f)"
134+ done
135+ if [[ -n $files ]]; then
136+ files=':args! '"$files<cr>"
137+ fi
138+ cmd="$before$files$after"
139+ gvim --remote-send "$cmd"
140+}
141+
142+alias v=callvim
143+alias vvsp="callvim -b':vsp'"
144+alias vhsp="callvim -b':sp'"
145+alias vk="callvim -b':wincmd k'"
146+alias vj="callvim -b':wincmd j'"
147+alias vl="callvim -b':wincmd l'"
148+alias vh="callvim -b':wincmd h'"