Skip to content

Commit 1a09439

Browse files
authored
Update README.md
1 parent acb9f08 commit 1a09439

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

README.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,34 @@
55
![Demo](https://i.imgur.com/dntK3MP.gif)
66

77

8-
You can use "exe" mode (flag `-e`):
9-
for example, to comment out in C++
10-
every line containing `my_bad_var`,
11-
then delete the line above it:
8+
Ever wish you could simply apply a vim command to every line
9+
in a command output automatically?
10+
If you use vim as your primary editor, this is likely much much easier
11+
than having to look up sed commands every time you filter a command output.
1212

13-
```
14-
cat my_script.cpp | vims -e 'my_bad_var' 'I//\<esc>kdd'
15-
```
13+
E.g., `cat file.txt | vims -l 'f|d$'` will go through every line, and run "f|d$",
14+
which is the vim command for deleting every character after "|".
15+
See below for many other useful features.
1616

17-
Which translates to `vims '%g/my_bad_var/exe "norm I//\<esc>kdd"'` - the `I` being the command
18-
to start insert at the start of the line, and `//` being the comment sequence.
19-
`\<esc>kdd` pushes the escape key, moves up a line, then deletes the line.
17+
# Install
2018

21-
```
22-
> echo 'Hello World!' | vims -s 'ea Beautiful'
23-
Hello Beautiful World!
24-
```
19+
To install, put `vims` somewhere on your path, e.g., `/usr/bin`.
2520

26-
- `-s` - Turn on simple mode (normal vim commands, start at char 0, line 0)
27-
- `ea` - Start inserting after end of first word
2821

29-
# Usage/Examples
22+
# Usage
3023

31-
To install,
32-
put `vims` somewhere on your path, e.g., `/usr/bin`.
24+
`... | vims ...`
25+
- (default) `-t [EX_CMD]` Ex mode. Works as if you typed ":" in vim.
26+
- `-s [CMD]` Simple command mode. Starts on the first line in command mode (e.g., `x` deletes a char).
27+
- `-l [CMD]` Line command mode. Runs the command on every line.
28+
- `-e [REGEX] [CMD]` Exe mode. Runs the command on every line matching `REGEX` (uses vim regex).
29+
- `-r [REGEX] [CMD]` Inverse exe mode. Runs the command on every line not matching `REGEX` (uses vim regex).
30+
- `-n` quiet. Don't print lines to stdout. You will then have to use `:p` command to print manually.
31+
32+
Note that for commands, you can write `\<esc>` to hit the escape key, or `\<c-o>` to hit ctrl-O.
3333

3434
```
35-
{command} | vims [-n|--quiet] [-d|--disable-vimrc]
35+
{command} | vims [-n|--quiet]
3636
[-e|--exe-mode] [-r|--inverse-exe-mode]
3737
[-s|--simple-mode] [-l|--line-exe-mode]
3838
[-t|--turn-off-mode]
@@ -43,6 +43,8 @@ Call `vims` on piped input, providing a list of arguments that you
4343
would use in vim command-line mode. All lines not deleted are printed
4444
by default, but you can turn this off with a `-n|--quiet` flag.
4545

46+
## Discussion:
47+
4648
Trigger "exe" mode using the `-e|--exe-mode` flag, which creates macros
4749
for `'%g/$1/exe "norm $2"'` (see [the power of `:g`](http://vim.wikia.com/wiki/Power_of_g)),
4850
where `$1` is the first arg of a pair,
@@ -64,9 +66,6 @@ Modes are activated for all the proceeding args. You can switch
6466
modes partway, by calling the flag for the other mode you want, or you
6567
can turn off any activated mode with `-t|--turn-off-mode`.
6668

67-
Your default vimrc should be enabled by default, turn it off with
68-
`-d|--disable-vimrc`.
69-
7069
## Example 1
7170
Delete lines 10-15, and print the remainder:
7271

0 commit comments

Comments
 (0)