Command line commands

The above operations concern local moves through a file. Absolute moves can be made to any line when its number is known. This is done via the command line. To this end, one presses the key marked <Esc> after which the cursor leaves the text area and reappears in the line at the bottom of the screen to wait for a command line command. The command to move to a given line can be given by just typing the line number followed by a return. The cursor will then reappear in the text window and the screen will be moved to the proper part of the file. This command would be used very frequently during the development of a program when a compiler tells the number of the line in which errors were found.

It is also possible to select the column to which the cursor is to be moved. The syntax of this statement is rather similar and actually together with the above command, it is part of a single more general command. With the cursor in the command line (via pressing the Escape key) type the line number desired, followed by a comma, then the column number desired and then type Return. This will result in the cursor moving to the designated line and column in the file corresponding to the numbers given. If the first number is omitted (i.e. just a comma followed by a number) the cursor moves to the designated column inside the current line. If the column number is omitted (the comma is then irrelevant and therefore not necessary) the column number will not be changed when the cursor is moved to the designated line. Finally this command has an option for very advanced programmers who like occasionally to go to a given character in the file which is known by its number in the file. For such a command one should type two comma's, followed by the number of the character.

There is still a class of commands that are specially designed for people who would like more flexibility. The cursor can be moved from the current line forward or back a designated number of lines. To move the cursor forward a given number of lines, go to the command line and type a plus sign followed by a number (+#) and <Return>, where # is the number of lines forward the cursor is to be moved. Similarly, to move backward a designated number of lines, type a minus sign and then a number (-#).

The first five spaces in the command line (the bottom line on the screen - sometimes called the message bar) indicate the line number of the cursor at any given time. If you would like more information about the location of the cursor, the command `=' in the command line will give a message in the command line that also tells the column number of the cursor. In addition, this command gives the following information. First, we have the character number the cursor would be on if the file would be written in its current form with the current settings (this is a function of whether the tabs would be expanded into blanks and how the end-of-line marks should be represented - see the chapter on File input and output). Next is the number of bytes that the whole file would occupy if written with the current settings. Then the line number of the cursor on the screen is given, followed by the column number of the cursor on the screen. The final number tells how many lines there are in the current buffer. An example is:

  231 bytes: 13612/22567 screen:21,1 lines 383
while the line number is 231. It indicates that there are 383 lines in the file and that the cursor is in column 1 (on the screen row 21, column 1) and that the byte position is 13612 out of 22567 bytes in total.