[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 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 section Optional Mode Line Features.
- M-=
Display the number of lines in the current region (
count-lines-region
). See section The Mark and the Region, 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 section Displaying the Cursor.
- M-x size-indication-mode
Toggle automatic display of the size of the buffer. See section Optional Mode Line Features.
M-x what-line displays the current line number
in the echo area. You can also see the current line number in the
mode line; see The Mode Line; but if you narrow the buffer, the
line number in the mode line is relative to the accessible portion
(see section 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. See section Pages.
Use M-= (count-lines-region
) to displays the number of
lines in the region (see section The Mark and the Region). See section Pages, for the command
C-x l which counts the lines in the current page.
The command C-x = (what-cursor-position
) shows what
cursor's column position, and other 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 section 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 start of the buffer is position 1, one character later is position 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 section 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 character.
-
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 keys to type to input the character in the current input method (if it supports the character).
- If you are running Emacs on a graphical display, the font name and glyph code for the character. If you are running Emacs on a text-only terminal, the code(s) sent to the terminal.
- The character's text properties (see (elisp)Text Properties section `Text Properties' in the Emacs Lisp Reference Manual), and any overlays containing it (see (elisp)Overlays section `Overlays' in the same manual).
Here's an example showing the Latin-1 character A with grave accent,
in a buffer whose coding system is iso-latin-1
, whose
terminal coding system is iso-latin-1
(so the terminal actually
displays the character as ‘À’), and which has font-lock-mode
(see section Font Lock mode) enabled:
character: À (2240, #o4300, #x8c0, U+00C0) charset: latin-iso8859-1 (Right-Hand Part of Latin Alphabet 1… code point: #x40 syntax: w which means: word category: l:Latin to input: type "`A" with latin-1-prefix buffer code: #x81 #xC0 file code: #xC0 (encoded by coding system iso-latin-1) display: terminal code #xC0 There are text properties here: fontified t |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |