Next: , Previous: , Up: Basic   [Contents][Index]


4.8 Cursor Position Information

If you are accustomed to other display editors, you may be surprised that Emacs does not always display the page number or line number of point in the mode line. In Emacs, this information is only rarely needed, and a number of commands are available to compute and print it. Since text is stored in a way that makes it difficult to compute the information, it is not displayed all the time.

M-x what-page

Print page number of point, and line number within page.

M-x what-line

Print line number of point in the buffer.

M-x line-number-mode

Toggle automatic display of current line number.

M-=

Print number of lines and characters in the current region (count-lines-region). See Mark, for information about the region.

C-x =

Print character code of character after point, character position of point, and column of point (what-cursor-position).

There are several commands for printing line numbers:

The command C-x = (what-cursor-position) can be used to find out the column that the cursor is in, and other miscellaneous information about point. It prints a line in the echo area that looks like this:

Char: c (0143, 99, 0x63)  point=18862 of 24800(76%)  column 53

(In fact, this is the output produced when point is before ‘column 53’ in the example.)

The four values after ‘Char:’ describe the character that follows point, first by showing it and then by giving its character code in octal, decimal and hex.

point=’ is followed by the position of point expressed as a character count. The front of the buffer counts as position 1, one character later as 2, and so on. The next, larger number is the total number of characters in the buffer. Afterward in parentheses comes the position expressed as a percentage of the total size.

column’ is followed by the horizontal position of point, in columns 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 invisible, C-x = prints additional text describing the current visible range. For example, it might say:

Char: c (0143, 99, 0x63)  point=19674 of 24575(80%) <19591 - 19703>  column 69

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 visible ones. See Narrowing.

If point is at the end of the buffer (or the end of the visible part), C-x = omits any description of the character after point. The output looks like

point=563026 of 563025(100%)  column 0

Next: , Previous: , Up: Basic   [Contents][Index]