8.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 the page.
- M-x what-line
- Display the line number of point in the buffer.
- M-x line-number-mode
- M-x column-number-mode
- Toggle automatic display of current line number or column number.
See Optional Mode Line.
- Display the number of lines in the current region (
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 (
- 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 computes the current line number and displays it
in the echo area. You can also see the current line number in the
mode line; see Mode Line. If you narrow the buffer, then the
line number in the mode line is relative to the accessible portion
(see Narrowing). By contrast,
what-line shows 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.
While on this subject, we might as well mention M-= (
which displays the number of lines in the region (see Mark).
See Pages, for the command C-x l which counts the lines in the
The command C-x = (
what-cursor-position) shows what
column the cursor is in, and other miscellaneous information about
point and the character after it. It displays a line in the echo area
that looks like this:
Char: c (99, #o143, #x63) point=28062 of 36168 (78%) column=53
The four values after ‘Char:’ describe the character that follows
point, first by showing it and then by giving its character code in
decimal, octal and hex. For a non-ASCII multibyte character, these are
followed by ‘file’ and the character's representation, in hex, in
the buffer's coding system, if that coding system encodes the character
safely and with a single byte (see Coding Systems). If the
character's encoding is longer than one byte, Emacs shows ‘file ...’.
However, if the character displayed is in the range 0200 through
0377 octal, it may actually stand for an invalid UTF-8 byte read from
a file. In Emacs, that byte is represented as a sequence of 8-bit
characters, but all of them together display as the original invalid
byte, in octal code. In this case, C-x = shows ‘part of
display ...’ instead of ‘file’.
‘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 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.
If point is at the end of the buffer (or the end of the accessible
part), the C-x = output does not describe a character after
point. The output might look like this:
point=36169 of 36168 (EOB) column=0
C-u C-x = displays the following additional information about a
- The character set name, and the codes that identify the character
within that character set; ASCII characters are identified
as belonging to the
ascii character set.
- The character's syntax and categories.
- The character's encodings, both internally in the buffer, and externally
if you were to save the file.
- What to type to input the character in the current input method
(if it supports the character).
- If you are running Emacs on a window system, the font name and glyph
code for the character. If you are running Emacs on a terminal, the
code(s) sent to the terminal.
- The character's text properties (see Text Properties), and any overlays containing it
Here's an example showing the Latin-1 character A with grave accent,
in a buffer whose coding system is
terminal coding system is
iso-latin-1 (so the terminal actually
displays the character as ‘À’), and which has font-lock-mode
(see Font Lock) enabled:
character: À (2240, #o4300, #x8c0, U+00C0)
(Right-Hand Part of Latin Alphabet 1...
code point: 
syntax: w which means: word
to input: type "`A" with [latin-1-prefix]
buffer code: #x81 #xC0
file code: ESC #x2C #x41 #x40 (encoded by coding system iso-2022-7bit)
display: terminal code #xC0
There are text properties here: