1. Home
  2. Computing & Technology
  3. Linux

Position Info

Emacs Documentation

By Juergen Haas, About.com

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.
  • M-=
    Display the number of lines in the current region (count-lines-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 (what-cursor-position).
  • M-x hl-line-mode
    Enable or disable highlighting of the current line. See Cursor Display.

There are two commands for working with line numbers. M-x what-line computes the current line number and displays it in the echo area. To go to a given line by number, use M-x goto-line; it prompts you for the number. These line numbers count from one at the beginning of the buffer.

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) can be used to find out the column that the cursor is in, and other miscellaneous information about point. It displays a line in the echo area that looks like this:

Char: c (0143, 99, 0x63) point=21044 of 26883(78%) column 53

(In fact, this is the output produced when point is before the column 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. For a non-ASCII multibyte character, these are followed by ext 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

* Emacs Manual Index

Explore Linux

More from About.com

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Software
  5. Editors
  6. Emacs
  7. Emacs Documentation - Position Info

©2008 About.com, a part of The New York Times Company.

All rights reserved.