Skip to content

Commit 88ca1d2

Browse files
committed
Explanation comments
1 parent 9670110 commit 88ca1d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

vims

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PRINT_ALL=1
44
DISABLE_VIMRC=0
55
MODE=none
66

7+
# This creates an array to store vim commands to run:
78
set -- "$@" '---vims-end---'
89
while :; do
910
case "$1" in
@@ -17,6 +18,10 @@ while :; do
1718
-t|--turn-off-mode) MODE=none;;
1819
*)
1920
case "$MODE" in
21+
# Each of these store a single command. For example,
22+
# -l makes MODE=line-exe, which then stores the command:
23+
# `-c :"%g/.*/exe "norm {CMD}"`, where {CMD} is the string
24+
# the user passes after `-l`.
2025
none) set -- "$@" -c "$1";;
2126
simple) set -- "$@" -c ":exe \"norm gg""$1""\"";;
2227
line-exe) set -- "$@" -c ":%g/.*/exe \"norm ""$1""\"";;
@@ -38,4 +43,5 @@ if [ "$DISABLE_VIMRC" -eq "1" ]; then
3843
set -- -u NONE "$@"
3944
fi
4045

46+
# Finally, we execute the stored array of vim commands:
4147
vim - -nes "$@" -c ':q!' | tail -n +2

0 commit comments

Comments
 (0)