Jean-Luc
Jean-Luc

Reputation: 3613

Vim: Why $ for end of line?

I'm new to Vim and am curious as to why $ would be used to go to the end of the line. So, for example, 0 taking me to the beginning makes at least some sort of sense (first number on keyboard goes to first letter of line---understandable).

Is there any logic behind $ or is it just totally arbitrary?

I was thinking $tart, until I remember it took me to the end!

Thanks!

Upvotes: 5

Views: 243

Answers (4)

William Pursell
William Pursell

Reputation: 212248

At some point it was arbitrary, but for decades $ has been the symbol to indicate the end of a string in a regular expression. vim is honoring historical precedent and making the keystroke very intuitive to people familiar with regular expression syntax.

Upvotes: 12

chepner
chepner

Reputation: 531075

It may go back to the use of $ as a string terminator in CP/M (much like \0 is the string terminator for C strings).

Why CP/M used it seems to remain a mystery.

Upvotes: 0

Kent
Kent

Reputation: 195049

if you know some regular expression, you would know that in regex, $ means the the end of line. I guess, vi/vim took that idea.

Upvotes: 2

Rahul Tripathi
Rahul Tripathi

Reputation: 172418

Dollar represents the end of line as it is used in Regex also. I think its arbitrary.

You can also use A to move to the end of the line and switch to editing mode

Upvotes: 2

Related Questions