Next: Arguments, Previous: Continuation Lines, Up: Basic
Here are commands to get information about the size and position of parts of the buffer, and to count lines.
count-lines-region
).
See Mark, for information about the region.
what-cursor-position
).
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. See Pages.
While on this subject, we might as well mention M-= (count-lines-region
),
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
current page.
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 character.
ascii
character set.
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 Font Lock) enabled:
character: À (2240, #o4300, #x8c0, U+00C0) charset: [latin-iso8859-1] (Right-Hand Part of Latin Alphabet 1... code point: [64] syntax: w which means: word category: l:Latin 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: fontified t