Here are a bunch of tips and tricks with Vim line numbers, wrapping, count, length and my favorite… modeline.
Vim line numbers
To show line numbers, type:
Hit ENTER. You can also use the abbreviated command:
To hide line numbers, type:
Vim line wrap
To line wrap, type:
To remove line wrap, type:
Vim line count
To determine the line count, go to the end of the file by pressing <SHIFT>+g.
Then press <CTRL>+g. A status line will display at the bottom of the editor window indicating the name of the file and what line you’re. Since you’re at the end of the file, your current line number is the total number of lines in the file.
Vim line length
To determine the length of a line, go to the end of the line by pressing <SHIFT>+4.
Then press <CTRL>+g. A status line will display at the bottom of the editor window indicating the name of the file, what line you’re on and also what column you’re on. The column indicates the column index of the last character of your current line. Thus, this is the length of your line.
For both line count and line length, Joshua Corbin added a comment below that the ruler setting “…adds two displays to the right side of the status line, one that shows where your cursor is, and the other which shows how far down the file you are.” To enable this setting, type:
The end result looks like this:
The Vim modeline allows you to customize Vim settings for that specific file. If you’re programming in the C language, add this to the bottom of your source code:
Vim will now turn on the autoindent setting. Any Vim setting can be set as needed in this manner.