CONTENTS | INDEX | PREV | NEXT

Sometimes, a command leaves an undesired argument lying around for the next
command in a sequence. This is one of the most irritating types of bug
in a macro, because it is hard to spot. As an example, consider a (part of
a) macro which is supposed to optionally find string string and put value
-1 in register A:

:s string ESC -1 uA

See? The search-result (if found) is -1. OUR -1 is interpreted as the next
part of an expression, which will evaluate as -1 -1 = -2! If string could
not be found, the bug does no harm in this case!

Finding this bug can be hell, but solving it is very simple. Use the ESC
command to cancel the argument (while taking care that no unwanted double-ESC
appears):

:s string ESC SPACE ESC -1 uA