@@ -4,6 +4,52 @@ PRINT_ALL=1
44DISABLE_VIMRC=0
55MODE=none
66
7+ # First, simply check if the user passed "-h" or "--help":
8+ if [ " $1 " = " -h" ] || [ " $1 " = " --help" ]; then
9+ cat << EOF
10+ {command} | vims [-n|--quiet]
11+ [-e|--exe-mode] [-r|--inverse-exe-mode]
12+ [-s|--simple-mode] [-l|--line-exe-mode]
13+ [-t|--turn-off-mode]
14+ [-h|--help]
15+ [ <args>... ]
16+ * (default) -t [EX_CMD] Ex mode. Works as if you typed ":" in vim.
17+ * -s [CMD] Simple command mode. Starts on the first line in command mode (e.g., x deletes a char).
18+ * -l [CMD] Line command mode. Runs the command on every line.
19+ * -e [REGEX] [CMD] Exe mode. Runs the command on every line matching REGEX (uses vim regex).
20+ * -r [REGEX] [CMD] Inverse exe mode. Runs the command on every line not matching REGEX (uses vim regex).
21+ * -n quiet. Dont print lines to stdout. You will then have to use :p command to print manually.
22+ * -h help. Print this help message.
23+
24+ Note that for commands, you can write \<esc> to hit the escape key, or \<c-o> to hit ctrl-O.
25+
26+ Call vims on piped input, providing a list of arguments that you
27+ would use in vim command-line mode. All lines not deleted are printed
28+ by default, but you can turn this off with a -n|--quiet flag.
29+
30+ Trigger "exe" mode using the -e|--exe-mode flag, which creates macros
31+ for %g/$1 /exe "norm $2 " (see [the power of :g](http://vim.wikia.com/wiki/Power_of_g)),
32+ where $1 is the first arg of a pair,
33+ and $2 is the last arg of a pair. This lets you type non-text characters,
34+ like \<esc>, \<c-o>, etc.
35+
36+ Likewise, -l|--line-exe-mode translates to %g/.*/exe "norm$1 ", meaning
37+ it executes a command on ALL lines.
38+ Inverse exe mode is done with the -r|--inverse-exe-mode flag, which
39+ does the same as exe mode, but only on lines NOT matching the regex.
40+
41+ Use simple mode with the -s|--simple-mode flag, which is as vanilla
42+ as it gets. This translates every passed argument to: exe "norm $1 ", meaning
43+ that you can run commands just like you opened the editor, starting
44+ at line 1. Use the same backslashes (\<enter>) as you do for exe mode.
45+
46+ Modes are activated for all the proceeding args. You can switch
47+ modes partway, by calling the flag for the other mode you want, or you
48+ can turn off any activated mode with -t|--turn-off-mode.
49+ EOF
50+ exit 0
51+ fi
52+
753# This creates an array to store vim commands to run:
854set -- " $@ " ' ---vims-end---'
955while : ; do
0 commit comments