Reputation: 119
I discovered VIM has internal variables count and prevcount. However the count variable is somehow different from prevcount as per the following examples...
echo v:prevcount
gives the last normal count value that you typed.
echo prevcount
gives error "undefined variable".
echo v:count
gives the value 0 seemingly every time.
echo count
also gives the value 0 every time.
So why didn't echo count
give an error like echo prevcount
did?
Note that echo l:count
also gives error "undefined variable", as does every other possible prefix except v:
.
Upvotes: 1
Views: 195
Reputation: 172648
You'll find the answer under :help v:count
:
[...] "count" also works, for backwards compatibility.
In early Vim versions, there was no v:
prefix. They later realized that it's better to have a dedicated namespace for internal variables. v:prevcount
was only introduced later, so there's no need to be backward compatible there. You should always use the v:count
variant today.
Upvotes: 4