: Learning GNU Emacs, 3rd Edition

2.1.3 Repeating Commands

2.1.3 Repeating Commands

Now let's learn some efficiency tricks. Emacs lets you repeat any command as many times as you want to. First, you can repeat a command any number of times by pressing M-n before the command, where n is the number of times you want to repeat it. This command is called the digit-argument command.

You can give M-n a large argument if you want it to repeat the command many times. For example, let's say you are editing a large file of 1000 lines. If you typed M-500 C-n, the cursor would move down 500 lines, to the halfway point in the file. If you give M-n a larger argument than it can execute, it repeats the command as many times as possible and then stops.

There's another multiplier command you can use, too: C-u (the universal-argument command). You can give C-u an argument just like you do M-n. Typing either M-5 or C-u 5 repeats the command that follows five times. But unlike M-n, C-u doesn't need an argument to repeat commands. With no argument, C-u executes the next command four times. If you type C-u C-u, it executes the command 16 times. In this way, you can stack up C-u's to make commands execute many times: 16, 64, 256, and so on.[11]


: 0.261. /Cache: 3 / 1