Monday, March 31, 2014

Basic Editing commands


                         Basic editing commands

One way that Emacs lets users work quickly and efficiently is by providing high-level commands for moving around in, and manipulating, text. There are commands that operate on characters, words, lines, sentences, paragraphs, pages, function definitions, whitespace, and more. You can use them anywhere you read or edit text: source code, web pages, shells, directory listings, email messages, and so on.

                        Moving around in buffers

The most basic buffer movement commands move point (the cursor) by rows (lines) or columns (characters):
C-fForward one character
C-nNext line
C-bBack one character
C-pPrevious line   

Here are some ways to move around in larger increments:
C-aBeginning of line
M-fForward one word
M-aPrevious sentence
M-vPrevious screen
M-<Beginning of buffer
C-eEnd of line
M-bBack one word
M-eNext sentence
C-vNext screen
M->End of buffer
When you get used to these keys, they're faster than their more familiar equivalents in other applications (Home, End, Ctrl+Left, etc.) because you don't have to move your hands from the touch typing position. And these keys are far faster than using a mouse to move around in a buffer.
Emacs often provides additional commands for moving around in context-specific ways (e.g. in source code, commands to move to the previous or next function definition).
Many of the above commands move to a location relative to your current position in the buffer, so you can use them repeatedly (e.g. C-p C-p C-p to move back three lines). You can use the prefix argument to save time: C-u followed by a number and a movement command repeats that command the specified number of times. You can also use M-[digit] instead of C-u [digit]. If you use C-u without specifying a digit, the default is 4. Omitting the digit can save time when you don't know precisely how many units you want to jump anyway.
C-u 3 C-pBack 3 lines
C-u 10 C-fForward 10 characters
M-1 M-0 C-fForward 10 characters
C-u C-nForward 4 lines
C-u C-u C-nForward 16 lines
C-u C-u C-u C-nForward 64 lines
You can jump directly to a particular line number in a buffer:
M-g gJump to specified line
Searching for text is a handy way to move around in a buffer. Think of search as just another facility for movement. When you're looking for something specific, you can use incremental search to take you right there instead of scanning by lines or pages. More about search later.
C-sIncremental search forward
C-rIncremental search backward

No comments:

Post a Comment