Skip to content

Commit ff82c04

Browse files
committed
Add section on selecting a region and commenting
1 parent e4732cf commit ff82c04

File tree

8 files changed

+2537
-1658
lines changed

8 files changed

+2537
-1658
lines changed

README.org

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ Remember one thing: Emacs is 30+ years old and brings new users everyday. It is
3838
- 2.1 [[./chapters/02-the-basics.org#config-files][Config files]]
3939
- 2.2 [[./chapters/02-the-basics.org#executing-commands][Executing commands]]
4040
- 2.3 [[./chapters/02-the-basics.org#key-bindings][Key bindings]]
41+
- 2.3.1 [[./chapters/02-the-basics.org#manipulate-files][Manipulate files]]
42+
- 2.3.2 [[./chapters/02-the-basics.org#manipulate-the-current-line][Manipulate the current line]]
43+
- 2.3.3 [[./chapters/02-the-basics.org#selecting-a-region][Selecting a region]]
44+
- 2.3.4 [[./chapters/02-the-basics.org#commenting][Commenting]]
45+
- 2.3.5 [[./chapters/02-the-basics.org#windows][Windows]]
46+
- 2.3.6 [[./chapters/02-the-basics.org#buffers][Buffers]]
47+
- 2.3.7 [[./chapters/02-the-basics.org#cancel-a-command][Cancel a command]]
48+
- 2.3.8 [[./chapters/02-the-basics.org#the-most-useless-command][The most useless command]]
4149
- 2.4 [[./chapters/02-the-basics.org#help][Help!]]
4250
- 3. [[./chapters/03-building-your-own-editor.org][Building your own editor]]
4351
- 3.1 [[./chapters/03-building-your-own-editor.org#first-basic-configuration][First basic configuration]]

chapters/02-the-basics.org

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,38 @@ How does it work?
7373
#+CAPTION: Line manipulation
7474
[[../images/line.gif]]
7575

76+
*** Selecting a region
77+
78+
Regions are selections, in Emacs.
79+
80+
They are composed by two points. A starting one and and an ending one.
81+
82+
To select the starting point, move your cursor to the wanted location and simply press *C-Space*. In your minibuffer, you should have seen a message like "Mark set".
83+
Now, move your cursor to the location you wantyour selection to end.
84+
85+
You have now a selection (or a /region/) delimited by the place you set the first mark and your cursor. With this region, you can do what ever you want:
86+
87+
- Copy (*M-w*)
88+
- Cut (*C-k*)
89+
- Paste (*C-y*)
90+
- Replace (*M-%*)
91+
- ... etc
92+
93+
#+CAPTION: Selecting a region
94+
[[../images/selecting.gif]]
95+
96+
*** Commenting
97+
98+
In order to comment a code block, select the region you want to comment and use:
99+
100+
- *M-x comment-region* in order to comment the block
101+
- *M-x uncomment-region* in order to uncomment the block
102+
103+
Of course, Emacs knows, according to the major mode loaded how to comment properly your code. If the major-mode is /ruby-mode/, it will add a "#" before the line; if the major-mode is /lisp-mode/, it will add ";;", and so on and so forth.
104+
105+
#+CAPTION: Commenting
106+
[[../images/comment.gif]]
107+
76108
*** Windows
77109

78110
This might be confusing but a /window/ is a part of a /frame/.

0 commit comments

Comments
 (0)