Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Why $ for end of line?

Tags:

vim

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!

like image 316
Jean-Luc Avatar asked Oct 22 '13 14:10

Jean-Luc


3 Answers

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.

like image 58
William Pursell Avatar answered Oct 09 '22 05:10

William Pursell


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

like image 23
Rahul Tripathi Avatar answered Oct 09 '22 06:10

Rahul Tripathi


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.

like image 2
Kent Avatar answered Oct 09 '22 06:10

Kent