Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

At the bottom right hand side of the vim editor, there are 2 numbers that display the row and column number in the following format:

495,30

But on certain lines, this format is used:

496,9-30

What does the above format with the - mean? The cursor is still on column 30 but what is that 9 ?

share|improve this question
add comment

3 Answers 3

up vote 5 down vote accepted

It refers to cursor position with respect to special characters (ie: tab).

Say your screen was like this (small screen, I know):

1 x x x x x x x x x x - - - - - - - - - - - - - - - 
2 - - - - - - - - - - - - - - - - - - - - - - - - -
3 - - - - - - - - - - - - - - - - - - - - - - - - - 
4 - - - - - - - - - - - - - - - - - - - - - - - - -
5 - - x            ---           ---          --- x
6 - - - - - - - - - - - - - - - - - - - - - - - - -
7 - - - - - - - - - - - - - - - - - - - - - - - - -
8 x x x x x x x x x x x x x x x x x x x x x x x x x

Any single character (except unicode) = 1 byte
3 attached lines (---) = Tab = 1 byte
1 space (-) = 1 byte

Tab is configured to display over 8 columns.

If your cursor was on the last X in line 1, Vim would show 1,10. If it was on the first X in line 5, it would show 5,3. The last X in line 8 represents 8,25. However, since the second X on line 5 is separated by 3 Tab sequences, if your cursor was on the last X, it would show 5,7-25.

  • The first 5 is obviously the line number
  • The 7 represents the byte number in the column (2 spaces, an x, 3 tabs, and the last x = 7)
  • The 25 represents the column as you see it in the console. Using 25 spaces would be at the same position as 2 spaces, an x, 3 tabs, and another x. As you can see, the 25th X in line 8 lines up with the last X in line 5.
share|improve this answer
    
+1 Excellent, thanks for the detailed explanation. –  Andreas Grech Dec 13 '09 at 22:51
add comment

In the examples above, the byte-number is smaller than screen-column (e.g. 9-30, 7-25). This occurs when the displayed single-byte character takes up more than one screen-column.

It is also possible to have the byte-number be larger than the screen-column. This occurs when more than one byte is displayed in one (or fewer) column(s). An example is multi-byte characters such as '\xa0' (in hex notation) which may show up on the screen in a single column.

As an example, in line 5, if the second character is two-bytes and the fourth-character is also two bytes, as you move along line 5, the column numbers change as follows:

5,1
5,2   (two-byte character, appears in a single column)
5,4-3
5,5-4 (two-byte character, appears in a single column)
5,7-5
share|improve this answer
add comment

From the Vim "options.txt" help page (emphasis mine):

If the number of characters displayed is different from the number of bytes in the text (e.g., for a TAB or a multi-byte character), both the text column (byte number) and the screen column are shown, separated with a dash.

For an empty line "0-1" is shown.

For an empty buffer the line number will also be zero: "0,0-1".

For instance, if the first character of a line were a tab, and Vim was configured to display tabs over 8 columns, your ruler would say 1-8 because a tab is still just one byte, but your cursor would be on the 8th column.

You would see similar situations while browsing files containing extended Unicode characters, since they require more than one byte to store but still use just one column on the screen.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.