Skip to content

Commit 7c5598c

Browse files
authored
Merge pull request #4 from MilesCranmer/help-msg
Create help message
2 parents 96d2ae7 + b270667 commit 7c5598c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ To install, put `vims` somewhere on your path, e.g., `/usr/bin`.
2828
- `-e [REGEX] [CMD]` Exe mode. Runs the command on every line matching `REGEX` (uses vim regex).
2929
- `-r [REGEX] [CMD]` Inverse exe mode. Runs the command on every line not matching `REGEX` (uses vim regex).
3030
- `-n` quiet. Don't print lines to stdout. You will then have to use `:p` command to print manually.
31+
- `-h` help. Print this documentation.
3132

3233
Note that for commands, you can write `\<esc>` to hit the escape key, or `\<c-o>` to hit ctrl-O.
3334

@@ -36,6 +37,7 @@ Note that for commands, you can write `\<esc>` to hit the escape key, or `\<c-o>
3637
[-e|--exe-mode] [-r|--inverse-exe-mode]
3738
[-s|--simple-mode] [-l|--line-exe-mode]
3839
[-t|--turn-off-mode]
40+
[-h|--help]
3941
[ <args>... ]
4042
```
4143

vims

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,52 @@ PRINT_ALL=1
44
DISABLE_VIMRC=0
55
MODE=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:
854
set -- "$@" '---vims-end---'
955
while :; do

0 commit comments

Comments
 (0)