Next: , Previous: Continuation Lines, Up: Basic


7.9 Cursor Position Information

Here are commands to get information about the size and position of parts of the buffer, and to count lines.

M-x what-page
Display the page number of point, and the line number within that page.
M-x what-line
Display the line number of point in the whole buffer.
M-x line-number-mode
M-x column-number-mode
Toggle automatic display of the current line number or column number. See Optional Mode Line.
M-x count-lines-region
Display the number of lines in the current region. Normally bound to M-=, except in a few specialist modes. See Mark, for information about the region.
C-x =
Display the character code of character after point, character position of point, and column of point (what-cursor-position).
M-x hl-line-mode
Enable or disable highlighting of the current line. See Cursor Display.
M-x size-indication-mode
Toggle automatic display of the size of the buffer. See Optional Mode Line.

M-x what-line displays the current line number in the echo area. This command is usually redundant, because the current line number is shown in the mode line (see Mode Line). However, if you narrow the buffer, the mode line shows the line number relative to the accessible portion (see Narrowing). By contrast, what-line displays both the line number relative to the narrowed region and the line number relative to the whole buffer.

M-x what-page counts pages from the beginning of the file, and counts lines within the page, showing both numbers in the echo area. See Pages.

Use M-x count-lines-region (normally bound to M-=) to display the number of lines in the region (see Mark). See Pages, for the command C-x l which counts the lines in the current page.

The command C-x = (what-cursor-position) shows information about the current cursor position and the buffer contents at that position. It displays a line in the echo area that looks like this:

     Char: c (99, #o143, #x63) point=28062 of 36168 (78%) column=53

After ‘Char:’, this shows the character in the buffer at point. The text inside the parenthesis shows the corresponding decimal, octal and hex character codes; for more information about how C-x = displays character information, see International Chars. After ‘point=’ is the position of point as a character count (the first character in the buffer is position 1, the second character is position 2, and so on). The number after that is the total number of characters in the buffer, and the number in parenthesis expresses the position as a percentage of the total. After ‘column=’ is the horizontal position of point, in columns counting from the left edge of the window.

If the buffer has been narrowed, making some of the text at the beginning and the end temporarily inaccessible, C-x = displays additional text describing the currently accessible range. For example, it might display this:

     Char: C (67, #o103, #x43) point=252 of 889 (28%) <231-599> column=0

where the two extra numbers give the smallest and largest character position that point is allowed to assume. The characters between those two positions are the accessible ones. See Narrowing.