-
Notifications
You must be signed in to change notification settings - Fork 139
/
emacs-tutor.html
6841 lines (5893 loc) · 210 KB
/
emacs-tutor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2016-11-04 Fri 22:29 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Emacs Mini Manual (PART 1) - THE BASICS</title>
<meta name="generator" content="Org-mode" />
<meta name="author" content="Tu Do" />
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}
pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
pre.src-sh:before { content: 'sh'; }
pre.src-bash:before { content: 'sh'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-R:before { content: 'R'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-java:before { content: 'Java'; }
pre.src-sql:before { content: 'SQL'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
/*]]>*/-->
</style>
<link rel="stylesheet" href="./static/worg.css">
<script type="text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.
Copyright (C) 2012-2013 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
displayAlign: "center",
displayIndent: "0em",
"HTML-CSS": { scale: 100,
linebreaks: { automatic: "false" },
webFont: "TeX"
},
SVG: {scale: 100,
linebreaks: { automatic: "false" },
font: "TeX"},
NativeMML: {scale: 100},
TeX: { equationNumbers: {autoNumber: "AMS"},
MultLineWidth: "85%",
TagSide: "right",
TagIndent: ".8em"
}
});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
</head>
<body>
<div id="preamble" class="status">
<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=9874755;
var sc_invisible=1;
var sc_security="c2028bb7";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" + scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="hit counter"
href="http://statcounter.com/free-hit-counter/" target="_blank"><img
class="statcounter" src="http://c.statcounter.com/9874755/0/c2028bb7/1/"
alt="hit counter"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->
<h2><a href="index.html">Back to Table of Contents</a></h2>
</div>
<div id="content">
<h1 class="title">Emacs Mini Manual (PART 1) - THE BASICS</h1>
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#orgheadline2">Why Emacs?</a></li>
<li><a href="#orgheadline3">Why this guide?</a></li>
<li><a href="#orgheadline4">A bit of history</a></li>
<li><a href="#orgheadline5">"I don't want a complicated editor, I want something simple like Notepad"</a></li>
<li><a href="#orgheadline6">Installation</a>
<ul>
<li><a href="#orgheadline7">Linux:</a></li>
<li><a href="#orgheadline8">Windows:</a></li>
<li><a href="#orgheadline9">Mac OS X:</a></li>
</ul>
</li>
<li><a href="#orgheadline10">Swap Control and Capslock</a>
<ul>
<li><a href="#orgheadline11">Windows</a></li>
<li><a href="#orgheadline12">Linux</a></li>
<li><a href="#orgheadline13">Mac OS X</a></li>
<li><a href="#orgheadline14">If you don't like to swap Capslock and Control…</a></li>
</ul>
</li>
<li><a href="#orgheadline15">Concepts</a>
<ul>
<li><a href="#orgheadline16">Command</a></li>
<li><a href="#orgheadline17">Emacs Key Notation</a></li>
<li><a href="#orgheadline18">Emacs Keys are easy to remember</a></li>
<li><a href="#orgheadline19">Ask for help - from Emacs</a>
<ul>
<li><a href="#orgheadline20">Built-in help system</a></li>
<li><a href="#orgheadline21">Info</a></li>
<li><a href="#orgheadline22">Man</a></li>
</ul>
</li>
<li><a href="#orgheadline23">Point</a></li>
<li><a href="#orgheadline24">Opening files</a></li>
<li><a href="#orgheadline25">Ido mode</a></li>
<li><a href="#orgheadline26">Buffer</a></li>
<li><a href="#orgheadline27">Major mode</a></li>
<li><a href="#orgheadline28">Minor mode</a></li>
<li><a href="#orgheadline29">Basic buffer managements</a></li>
<li><a href="#orgheadline30">Bookmark: save locations across Emacs sessions</a></li>
<li><a href="#orgheadline31">Basic motion commands</a></li>
<li><a href="#orgheadline32">Useful built-in key bindings for navigating pairs</a></li>
<li><a href="#orgheadline33">Basic editing commands</a></li>
<li><a href="#orgheadline34">Dynamic Abbreviations</a></li>
<li><a href="#orgheadline35">Kill ring</a></li>
<li><a href="#orgheadline36">Mark and region</a></li>
<li><a href="#orgheadline37">Mark ring</a></li>
<li><a href="#orgheadline38">Global mark ring</a></li>
<li><a href="#orgheadline39">Undo/redo</a></li>
<li><a href="#orgheadline40">Search for text</a>
<ul>
<li><a href="#orgheadline41">Incremental search</a></li>
<li><a href="#orgheadline42">Occur</a></li>
<li><a href="#orgheadline43">Query replace</a></li>
<li><a href="#orgheadline44">Multi-occur</a></li>
<li><a href="#orgheadline45">Grep</a></li>
</ul>
</li>
<li><a href="#orgheadline46">Modeline</a></li>
<li><a href="#orgheadline47">Minibuffer</a></li>
<li><a href="#orgheadline48">Echo area</a></li>
<li><a href="#orgheadline49">Frames</a></li>
<li><a href="#orgheadline50">Window</a></li>
<li><a href="#orgheadline51">Prefix Arguments</a></li>
<li><a href="#orgheadline52">Basic file management with Dired</a>
<ul>
<li><a href="#orgheadline53">Enter Dired</a></li>
<li><a href="#orgheadline54">Navigation</a></li>
<li><a href="#orgheadline55">Create files</a></li>
<li><a href="#orgheadline56">Visit files</a></li>
<li><a href="#orgheadline57">File Marking</a></li>
<li><a href="#orgheadline58">Operating on files</a></li>
<li><a href="#orgheadline59">Deleting files</a></li>
<li><a href="#orgheadline60">Execute shell commands in Dired</a></li>
<li><a href="#orgheadline61">Compare files</a></li>
<li><a href="#orgheadline62">Subdirectories</a></li>
</ul>
</li>
<li><a href="#orgheadline63">Registers</a>
<ul>
<li><a href="#orgheadline64">Save window configuration</a></li>
<li><a href="#orgheadline65">Save frame configuration</a></li>
<li><a href="#orgheadline66">Save text</a></li>
<li><a href="#orgheadline67">Save rectangles</a></li>
<li><a href="#orgheadline68">Save position</a></li>
<li><a href="#orgheadline69">Save numbers</a></li>
</ul>
</li>
<li><a href="#orgheadline70">Macro</a>
<ul>
<li><a href="#orgheadline71">Keyboard macro ring</a></li>
<li><a href="#orgheadline72">The Keyboard Macro Counter</a></li>
<li><a href="#orgheadline73">Macros with Variations</a></li>
<li><a href="#orgheadline74">Naming and Saving Macro</a></li>
<li><a href="#orgheadline75">Edit Keyboard Macro</a></li>
<li><a href="#orgheadline76">Interactive Keyboard Macro Editing:</a></li>
<li><a href="#orgheadline77">Tips for using macro effectively</a></li>
</ul>
</li>
<li><a href="#orgheadline78">Version Control</a></li>
<li><a href="#orgheadline79">Shell</a></li>
</ul>
</li>
<li><a href="#orgheadline80">Project: Browsing Linux kernel source code like a pro</a>
<ul>
<li><a href="#orgheadline81">Setup</a></li>
<li><a href="#orgheadline82">Browsing the kernel source tree</a></li>
</ul>
</li>
<li><a href="#orgheadline83">Extending Emacs Primer</a></li>
<li><a href="#orgheadline84">Conclusion</a></li>
<li><a href="#orgheadline1">Appendix</a>
<ul>
<li><a href="#orgheadline85">Why Emacs? (Extended)</a></li>
<li><a href="#orgheadline86">Other people's "Why Emacs?"</a></li>
<li><a href="#orgheadline87">More on Emacs history</a></li>
</ul>
</li>
</ul>
</div>
</div>
<p>
<b><span class="underline">Before we start</span></b>:
</p>
<ul class="org-ul">
<li>Please remember that you can always access a section using the
floating table of contents at the upper-right corner of your
screen.</li>
<li>Many people asked how this manual can be "mini", since it is pretty
big for an online single page article. Yes, if this page is exported
to PDF, it is more than 40 pages. However, this manual is "mini"
relative to the size of the official Emacs manual, which is more
than 600 pages. That's why.</li>
<li>If you find the page is loading too slow for you, you can always
clone the git repo of this mini manual and read it offline:
<a href="https://github.com/tuhdo/tuhdo.github.io">https://github.com/tuhdo/tuhdo.github.io</a></li>
</ul>
<div id="outline-container-orgheadline2" class="outline-2">
<h2 id="orgheadline2"><a id="ID-76607dbd-b97c-43dd-975b-3236192408b6"></a>Why Emacs?</h2>
<div class="outline-text-2" id="text-orgheadline2">
<p>
In Emacs, you can do many things aside from editing. Emacs is a
programming platform, not just another editor in the sense that people
think. For more details, read the <a href="#orgheadline1">Appendix</a>.
</p>
<p>
Take a <a href="http://www.gnu.org/software/emacs/tour/">tour</a> from the official Emacs homepage.
</p>
<p>
Here is my personal tour, <b>with 3rd party plugins added</b>. Don't worry
if your Emacs does not look like the screenshots. You can have
something like mine and even better, but for now you need to get a
solid foundation. The screenshots are just for show. Even though,
after going through this guide, you will be able to browse the Linux
kernel source tree with ease.
</p>
<ul class="org-ul">
<li><p>
Performance: Editing a 39MB C source file with no problem. But well,
it's not your favorite editor's fault if it crashes from editing
such a large source file.
</p>
<div class="figure">
<p><a href="static/performance.gif"><img src="static/performance.gif" alt="performance.gif" /></a>
</p>
</div></li>
<li>Programming:
<ul class="org-ul">
<li><p>
Jump to any header file:
</p>
<div class="figure">
<p><a href="static/jump_headers.gif"><img src="static/jump_headers.gif" alt="jump_headers.gif" /></a>
</p>
</div></li>
<li><p>
Autocompletion: Pay attention to completion candidates when
<code>include <linux/printk.h></code> is present and when it's not.
</p>
<div class="figure">
<p><a href="static/auto_complete.gif"><img src="static/auto_complete.gif" alt="auto_complete.gif" /></a>
</p>
</div></li>
<li><p>
Showing function arguments:
</p>
<div class="figure">
<p><a href="static/func_args.jpg"><img src="static/func_args.jpg" alt="func_args.jpg" /></a>
</p>
</div></li>
<li><p>
Quickly comment multiple lines:
</p>
<div class="figure">
<p><a href="static/comment.gif"><img src="static/comment.gif" alt="comment.gif" /></a>
</p>
</div></li>
<li><p>
GDB:
</p>
<div class="org-center">
<div class="figure">
<p><a href="static/c-ide/gdb-many-windows.gif"><img src="static/c-ide/gdb-many-windows.gif" alt="gdb-many-windows.gif" /></a>
</p>
</div>
</div></li>
</ul></li>
<li><p>
Diff between current editing file and latest file revision:
</p>
<div class="figure">
<p><a href="static/vc-diff.jpg"><img src="static/vc-diff.jpg" alt="vc-diff.jpg" /></a>
</p>
</div></li>
<li><p>
Magit: From unstage -> stage -> commit -> push
</p>
<div class="figure">
<p><a href="static/magit.gif"><img src="static/magit.gif" alt="magit.gif" /></a>
</p>
</div></li>
<li><p>
Live Grep:
</p>
<div class="figure">
<p><a href="static/live_grep.gif"><img src="static/live_grep.gif" alt="live_grep.gif" /></a>
</p>
</div></li>
<li><p>
Quickly select any file in a directory under a Version Control
System, for example from the Linux kernel. Note that in the demos
you may see me type in the commands. You can think of it like the
start menu in Windows, but those commands can actually be executed
quickly with a shortcut.
</p>
<div class="figure">
<p><a href="static/helm-projectile/helm-projectile-find-files-1.gif"><img src="static/helm-projectile/helm-projectile-find-files-1.gif" alt="helm-projectile-find-files-1.gif" /></a>
</p>
</div></li>
<li><p>
Quickly select any file/directory from a previous working session:
</p>
<div class="figure">
<p><a href="static/helm-buffer-list.gif"><img src="static/helm-buffer-list.gif" alt="helm-buffer-list.gif" /></a>
</p>
</div></li>
<li><p>
Emacs is a PDF Reader: I can search text in the PDF file with
highlighting and a table of contents side by side. All can be
controlled with keyboard.
</p>
<p>
<a href="static/emacs-read-pdf.gif"><img src="static/emacs-read-pdf.gif" alt="emacs-read-pdf.gif" /></a>/
</p></li>
</ul>
<p>
Finally, <a href="http://jtnimoy.net/workviewer.php?q=178">Emacs is featured in Tron Legacy</a>.
</p>
</div>
</div>
<div id="outline-container-orgheadline3" class="outline-2">
<h2 id="orgheadline3"><a id="ID-6cbf58f3-6986-4c27-8e04-f25c8bec778a"></a>Why this guide?</h2>
<div class="outline-text-2" id="text-orgheadline3">
<p>
Let's look at part of the Emacs manual:
</p>
<div class="figure">
<p><a href="static/emacs-manual-toc.gif"><img src="static/emacs-manual-toc.gif" alt="emacs-manual-toc.gif" /></a>
</p>
</div>
<p>
"All about handling files" is inside the <code>Files</code> entry, which includes
how to open files, save files, revert and auto-revert files, compare
files…, many things from basic to advanced. If you are a beginner
reading the Emacs manual, you have to actively search the manual to
learn how to do the basic common tasks you know from other editors.
</p>
<p>
It would take a long time before you can start using Emacs for basic
operations (e.g. opening files) if you read the manual cover to
cover. The "Fundamental Editing Commands" section is placed before the
"Major Structures of Emacs" section that contains information on file
handling. How can you learn the basic editing commands if you don't
even know how to open a file? The problem with the manual is that it's
not organized for a new Emacs user to progressively learn Emacs.
</p>
<p>
I want to help you use Emacs efficiently in a relatively short amount
of time, probably around a week. That's why I wrote this guide
especially for complete beginners. The Emacs manual is excellent, but
it would be much easier with a solid ground understanding and after
using Emacs for a while.
</p>
<p>
This guide provides a good starting point for the official Emacs
manual. The GNU Emacs tour would be a nice tutorial, only if it isn't
made for demonstration.
</p>
</div>
</div>
<div id="outline-container-orgheadline4" class="outline-2">
<h2 id="orgheadline4"><a id="ID-c8f88c3a-ecad-433d-931b-2cca8a4f62ac"></a>A bit of history</h2>
<div class="outline-text-2" id="text-orgheadline4">
<p>
Quote from GNU Emacs homepage:
</p>
<blockquote>
<p>
For those curious about Emacs history: Emacs was originally
implemented in 1976 on the MIT AI Lab's Incompatible Timesharing
System (ITS), as a collection of TECO macros. The name “Emacs” was
originally chosen as an abbreviation of “Editor MACroS”. This version
of Emacs, GNU Emacs, was originally written in 1984. For more
information, see the 1981 paper by Richard Stallman, describing the
design of the original Emacs and the lessons to be learned from it,
and a transcript of his 2002 speech at the International Lisp
Conference, My Lisp Experiences and the Development of GNU Emacs. Here
is the cover of the original Emacs Manual for ITS; the cover of the
original Emacs Manual for Twenex; and (the only cartoon RMS has ever
drawn) the Self-Documenting Extensible Editor.
</p>
</blockquote>
</div>
</div>
<div id="outline-container-orgheadline5" class="outline-2">
<h2 id="orgheadline5"><a id="ID-45226aea-d1af-4853-8be9-5dc1ee962973"></a>"I don't want a complicated editor, I want something simple like Notepad"</h2>
<div class="outline-text-2" id="text-orgheadline5">
<p>
Well, that's your choice. But I suggest that writing code without any
support is harmful.
</p>
<p>
A programmer should automate things as much as possible if the
automation cost does not outweigh the cost of doing it manually. One
<i>really easy</i> way to do this is by using a good editor that automates
many menial and tedious tasks. For example, one of the things that
annoy me is using the command <b>cd</b> to change into a deep directory
path like this:
</p>
<p>
<code>/path/to/a/very/long/long/long/long/long/long/..../directory/</code>
</p>
<p>
In Emacs, if you have a directory under a version control system, you
can immediately jump to any file quickly, even if it is buried 20
levels deep (as demonstrated at the beginning).
</p>
<p>
Another example is quickly commenting out multiple lines of code in a
programming language that only supports single line comments. In many
editors you would have to tediously comment them out line by line. But
in Emacs you can simply highlight the lines and press a shortcut to
comment them out.
</p>
<p>
Many people think that writing programs manually makes them much
cooler than "amateurs" that use a fancy <code>Integrated Development
Environment</code>. I also used to think like that because working in a
Linux environment requires understanding of the underlying processes,
such as building software using a Makefile in C/C++, automating with a
shell script, installing software by compiling… And this is already
considered "user friendly" in the Linux world, as opposed to "click
the nice little play button" in a typical IDE. However, I was
wrong. While working with such tools allows me to understand what's
going on, I do not need to type in code manually to understand it. If
you get what a for loop does, typing it character by character is only
tedious and interrupts your thinking.
</p>
<p>
Writing code manually won't make you smarter, because you did the
thinking before you started to type. Typing is just a mere reflection
of your thoughts into the editor. You need to finish typing as fast as
possible, because the quicker you finish, the quicker you can get back
to your thinking. Only thoughts matter, and there's no value in
manually typing the same things thousands of times. I must say, <code>Cut</code>,
<code>Copy</code> and <code>Paste</code> are really great ideas and great automation tools
because of their simplicity.
</p>
<p>
If your job may require you to use an esoteric in-house programming
language and if you don't like it, having an editor to help you finish
the tasks as soon as possible is a way to make yourself happier.
</p>
<p>
Typing too much can also lead to RSI. Manually typing too much code is
harmful to your fingers. At least if you use a handsaw instead of a
circular saw, you do some physical exercise in the process.
</p>
<p>
In Sum:
</p>
<ul class="org-ul">
<li>Manually typing does not make you smarter. Not in any form.</li>
<li>Manually typing does not make you a better programmer.</li>
<li>Manually typing or other tedious tasks (navigating the file system,
remembering changes you made to your files…) are a waste of time if
automating is possible. Automate as much as you can.</li>
<li>Good editors help you automate boring tasks.</li>
<li>Typing too much potentially leads to RSI.</li>
</ul>
<p>
Instead of wasting your time and memory on tedious tasks, you could
save it for more interesting things.
</p>
</div>
</div>
<div id="outline-container-orgheadline6" class="outline-2">
<h2 id="orgheadline6"><a id="ID-3ca43124-6e45-4ef6-a23e-628207936155"></a>Installation</h2>
<div class="outline-text-2" id="text-orgheadline6">
</div>
<div id="outline-container-orgheadline7" class="outline-3">
<h3 id="orgheadline7"><a id="ID-8acc1c68-72e7-4116-8afd-2265dda008d2"></a>Linux:</h3>
<div class="outline-text-3" id="text-orgheadline7">
<p>
Easy way to install if you are using Ubuntu: <code>sudo apt-get install
emacs</code>. If you use other Linux distributions, use the package manager
of your distribution and install Emacs. However, the package manager
only has the latest stable Emacs; if you want the latest Emacs, build
it from source according to the instructions below.
</p>
<p>
To use Emacs with GUI:
</p>
<ul class="org-ul">
<li>Install GTK 3: <code>sudo apt-get install libgtk-3-dev libgtk-3-common libgtk-3-0</code></li>
<li>Download <a href="http://www.gnu.org/software/emacs/">Emacs</a>; or if you prefer the latest Emacs, get it from source: <code>git clone http://repo.or.cz/r/emacs.git</code></li>
<li>If you download from the homepage, unpackage: <code>tar xvf
emacs-*.tar.gz</code></li>
<li>Install GTK: <code>sudo apt-get install libgtk-3-dev libgtk-3-common
libgtk-3-0</code>. You have to use gtk3 to be able to use true type
fonts.</li>
<li><code>cd emacs-<version>*</code></li>
<li><code>./autogen.sh</code></li>
<li><p>
Add prefix and path to where you want to install. This is useful if
you work on a remote server without root access: <code>./configure
--with-x-toolkit=gtk3 [--prefix=/path/to/dir]</code>
</p>
<p>
You should use GTKx 3, so you will be able to use true type fonts
such as Inconsolata for a better Emacs experience.
</p></li>
<li><code>make</code></li>
<li><code>sudo make install</code></li>
</ul>
<p>
If <code>./configure</code> tells you there are dependencies missing, you should
install them. Recommended dependencies: libtiff, libgiff, libjpeg,
libpng and libxml2 for viewing and browsing web inside Emacs:
</p>
<p>
<code>sudo apt-get install libtiff5-dev libpng12-dev libjpeg-dev libgif-dev
libgnutls-dev libxml2-dev</code>
</p>
<p>
Using in Terminal only:
</p>
<ul class="org-ul">
<li>Download and unpackage as above.</li>
<li><code>./configure --without-x [--prefix=/path/to/dir]</code></li>
<li><code>make</code></li>
<li><code>sudo make install</code></li>
</ul>
<p>
If you don't like to compile Emacs yourself, install from the package
manager of your Linux distribution.
</p>
<p>
After installation is done, add this line to your <b>.bashrc</b> or <b>.zshrc</b>:
</p>
<div class="org-src-container">
<pre class="src src-shell-script"><span style="color: #483d8b;">alias</span> <span style="color: #a0522d;">em</span>=<span style="color: #8b2252;">'emacs'</span>
</pre>
</div>
<p>
So you can start Emacs as fast as vim!
</p>
</div>
</div>
<div id="outline-container-orgheadline8" class="outline-3">
<h3 id="orgheadline8"><a id="ID-301e3dcb-a00d-4b20-a5a8-f2b0946c56d1"></a>Windows:</h3>
<div class="outline-text-3" id="text-orgheadline8">
<p>
You can either download it on GNU Emacs homepage or better, download
the latest 64 bit version:
<a href="http://semantic.supelec.fr/popineau/programming-emacs.html">http://semantic.supelec.fr/popineau/programming-emacs.html</a>.
</p>
<p>
After that, unpackage it in <code>C:\Program Files\</code> and create a shortcut
to <code>C:\Program Files\Emacs\bin\emacsclientw.exe</code> on desktop.
</p>
</div>
</div>
<div id="outline-container-orgheadline9" class="outline-3">
<h3 id="orgheadline9"><a id="ID-f86712b7-d138-4ad3-aef0-494a744c3b34"></a>Mac OS X:</h3>
<div class="outline-text-3" id="text-orgheadline9">
<p>
Download compiled Emacs for Mac OS X: <a href="http://emacsformacosx.com/">http://emacsformacosx.com/</a>.
</p>
<p>
You can also use this version that is more integrated with Mac OSX:
<a href="https://github.com/railwaycat/emacs-mac-port">https://github.com/railwaycat/emacs-mac-port</a>
</p>
</div>
</div>
</div>
<div id="outline-container-orgheadline10" class="outline-2">
<h2 id="orgheadline10"><a id="ID-4e00a8da-dbf0-4156-81e8-c6ed0f5c58f5"></a>Swap Control and Capslock</h2>
<div class="outline-text-2" id="text-orgheadline10">
<p>
Swapping Control and Capslock, in general, is not required to make the
best out of Emacs, if you at least use a regular key PC keyboard or
better. However, it is not nice at all on a laptop keyboard. If you
use a laptop keyboard for writing code, I strongly recommended to swap
Control and Capslock for a better Emacs experience.
</p>
<p>
Swapping Control and Caplock will not only benefit your Emacs usage,
it is beneficial in general, as Control is a much more frequently used
key than Capslock. Popular shells like Bash or Zsh use Control a lot
for quick cursor movement.
</p>
</div>
<div id="outline-container-orgheadline11" class="outline-3">
<h3 id="orgheadline11"><a id="ID-eb9ffe1f-f726-4b15-8431-b075e9ba234d"></a>Windows</h3>
<div class="outline-text-3" id="text-orgheadline11">
<p>
Follow this guide: <a href="http://www.kodiva.com/post/swapping-caps-lock-and-control-keys">Swapping Capslock and Control keys</a>
</p>
</div>
</div>
<div id="outline-container-orgheadline12" class="outline-3">
<h3 id="orgheadline12"><a id="ID-32a786e9-ae18-4c7b-9d12-1940e4f2d301"></a>Linux</h3>
<div class="outline-text-3" id="text-orgheadline12">
<p>
Put this in your shell init file (.bashrc, .zshrc…):
</p>
<div class="org-src-container">
<pre class="src src-shell-script">/usr/bin/setxkbmap -option <span style="color: #8b2252;">"ctrl:swapcaps"</span>
</pre>
</div>
<p>
If you use Ubuntu, follow this guide: <a href="http://askubuntu.com/a/412622/13847">Swap caps lock and ctrl in
ubuntu 13.10</a>.
</p>
</div>
</div>
<div id="outline-container-orgheadline13" class="outline-3">
<h3 id="orgheadline13"><a id="ID-dc1f00fd-29a6-45e0-8398-211418cba728"></a>Mac OS X</h3>
<div class="outline-text-3" id="text-orgheadline13">
<p>
Follow this answer on StackOverflow: <a href="http://stackoverflow.com/a/162907/496700">Emacs on Mac OS X Leopard key
bindings</a>
</p>
</div>
</div>
<div id="outline-container-orgheadline14" class="outline-3">
<h3 id="orgheadline14"><a id="ID-cefa92ca-8234-44bf-9ae5-66dc76aadd0d"></a>If you don't like to swap Capslock and Control…</h3>
<div class="outline-text-3" id="text-orgheadline14">
<p>
You can use your palm to press Control in standard PC keyboard.
</p>
</div>
</div>
</div>
<div id="outline-container-orgheadline15" class="outline-2">
<h2 id="orgheadline15"><a id="ID-dc9722bb-91fb-4f38-b701-ffd3fb84d4c7"></a>Concepts</h2>
<div class="outline-text-2" id="text-orgheadline15">
</div>
<div id="outline-container-orgheadline16" class="outline-3">
<h3 id="orgheadline16"><a id="ID-4bb52c4a-1d30-42e0-999b-b18d8831997e"></a>Command</h3>
<div class="outline-text-3" id="text-orgheadline16">
<p>
In Emacs, every user interaction is a function execution. You press a
key to insert a character, Emacs runs <code>self-insert-command</code>. There are
two types of functions in Emacs:
</p>
<ul class="org-ul">
<li><b>Normal functions</b>: These are like functions in other
programming languages, and are used for implementing features in
Emacs. Users do not need to care about these functions, unless
they want to implement something or modify an existing
implementation.</li>
<li><b>Commands</b>: Commands are like functions, but interactive. It
means, commands are features provided to users and users
directly use them.</li>
</ul>
<p>
<code>execute-extended-command</code> is bound to <b>M-x</b>.
</p>
</div>
</div>
<div id="outline-container-orgheadline17" class="outline-3">
<h3 id="orgheadline17"><a id="ID-c428fffd-3636-43e4-916e-9bc67c48db4e"></a>Emacs Key Notation</h3>
<div class="outline-text-3" id="text-orgheadline17">
<p>
Taken from here: <a href="http://www.emacswiki.org/emacs/EmacsKeyNotation">EmacsWiki</a>
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Prefix</th>
<th scope="col" class="org-left">Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left"><code>C-</code></td>
<td class="org-left">(press and hold) the Control key</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left"><code>M-</code></td>
<td class="org-left">the Meta key (the Alt key, on most keyboards)</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left"><code>S-</code></td>
<td class="org-left">the Shift key (e.g.‘S-TAB’ means Shift Tab)</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left"><code>DEL</code></td>
<td class="org-left">the Backspace key (not the Delete key). Inside Emacs, <code>DEL</code></td>
</tr>
<tr>
<td class="org-left"> </td>
<td class="org-left">is written as <code><backspace></code>.</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left"><code>RET</code></td>
<td class="org-left">the Return or Enter key</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left"><code>SPC</code></td>
<td class="org-left">the Space bar key</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left"><code>ESC</code></td>
<td class="org-left">the Escape key</td>
</tr>
</tbody>
<tbody>
<tr>
<td class="org-left"><code>TAB</code></td>
<td class="org-left">the TAB key</td>
</tr>
</tbody>
</table>
<p>
A notation such as <b>C-M-x</b> (or, equivalently, <b>M-C-x</b>) means press and
hold both Control and Meta (Alt) keys while hitting the <b>x</b> key. From
now on, I won't say something like "Press <b>M-x</b>" anymore. For example,
if I say "<b>C-x C-f</b> your files", you should replace <b>C-x C-f</b> with its
command like this in your head: "<code>find-file</code> your files". All commands
use verbs, I think, so don't worry. Try to recall the command from the
key binding; it will help you get used to Emacs quicker. One exception
though: I only say "press <b>key</b>" if <b>key</b> is a single character on the
keyboard.
</p>
<p>
If you see <code>M-x command</code>, it means you need to <b>M-x</b> and type
<b>command</b>.
</p>
<p>
A prefix key is a part of a full key binding. For example, a full key
binding is <b>C-x r l</b> to run the command <code>bookmark-bmenu-list</code>, then
<b>C-x</b> and <b>C-x r</b> are its prefixes. Note that key sequence such as
<b>C-x</b> and <b>M-x</b> are considered a single character. Knowing prefix key
is handy: if you forget key bindings of some commands that use the
same prefix key, and remember the prefix, you can press the prefix key
and <b>C-h</b> to get a list of commands with that prefix.
</p>
<p>
For example, <b>C-x r</b> is the prefix for <i>register</i> and <i>bookmark</i>
commands in Emacs. However, you forget a specific key binding for a
command in those features. <b>C-x r C-h</b> lists all key bindings that have
prefix <b>C-x r</b>.
</p>
<p>
Finally, <b>C-g</b> executes the command <code>keyboard-quit</code>, which cancels anything
Emacs is executing. If you press any key sequence wrongly, <b>C-g</b> to
cancel that incorrectly pressed key sequence and start again.
</p>
<p>
As you gradually learn Emacs, you will see the key bindings are really
systematically organized and mnemonic. Whenever you see key bindings
ending with <b>n</b> and <b>p</b>, it usually means <b>next</b> and <b>previous</b>; <b>o</b>
means <b>open</b>; <b>h</b> means <b>help</b>; <b>C-h</b> is standard prefix for help
commands; key bindings such as <b>o</b> and <b>C-o</b> are frequently used in
many built-in tools such as <i>Dired</i>, <i>Ibuffer</i>, <i>Occur</i>…
</p>
</div>
</div>
<div id="outline-container-orgheadline18" class="outline-3">