-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy path0.4.html
1046 lines (529 loc) · 45.4 KB
/
0.4.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
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Configuring vim · GitBook</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-intopic-toc/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-page-footer-ex/style/plugin.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-callouts/plugin.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-theme-comscore/test.css">
<link rel="stylesheet" href="styles.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="0.5.html" />
<link rel="prev" href="0.3.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="index.html">
<a href="index.html">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="PA0.html">
<a href="PA0.html">
PA0 - 世界诞生的前夜: 开发环境配置
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="0.1.html">
<a href="0.1.html">
Installing GNU/Linux
</a>
</li>
<li class="chapter " data-level="1.2.2" data-path="0.2.html">
<a href="0.2.html">
First Exploration with GNU/Linux
</a>
</li>
<li class="chapter " data-level="1.2.3" data-path="0.3.html">
<a href="0.3.html">
Installing Tools
</a>
</li>
<li class="chapter active" data-level="1.2.4" data-path="0.4.html">
<a href="0.4.html">
Configuring vim
</a>
</li>
<li class="chapter " data-level="1.2.5" data-path="0.5.html">
<a href="0.5.html">
More Exploration
</a>
</li>
<li class="chapter " data-level="1.2.6" data-path="0.6.html">
<a href="0.6.html">
Getting Source Code for PAs
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="PA1.html">
<a href="PA1.html">
PA1 - 开天辟地的篇章: 最简单的计算机
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="1.1.html">
<a href="1.1.html">
在开始愉快的PA之旅之前
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="1.2.html">
<a href="1.2.html">
开天辟地的篇章
</a>
</li>
<li class="chapter " data-level="1.3.3" data-path="1.3.html">
<a href="1.3.html">
RTFSC
</a>
</li>
<li class="chapter " data-level="1.3.4" data-path="1.4.html">
<a href="1.4.html">
基础设施
</a>
</li>
<li class="chapter " data-level="1.3.5" data-path="1.5.html">
<a href="1.5.html">
表达式求值
</a>
</li>
<li class="chapter " data-level="1.3.6" data-path="1.6.html">
<a href="1.6.html">
监视点
</a>
</li>
<li class="chapter " data-level="1.3.7" data-path="1.7.html">
<a href="1.7.html">
如何阅读手册
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="PA2.html">
<a href="PA2.html">
PA2 - 简单复杂的机器: 冯诺依曼计算机系统
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="2.1.html">
<a href="2.1.html">
不停计算的机器
</a>
</li>
<li class="chapter " data-level="1.4.2" data-path="2.2.html">
<a href="2.2.html">
RTFSC(2)
</a>
</li>
<li class="chapter " data-level="1.4.3" data-path="2.3.html">
<a href="2.3.html">
程序, 运行时环境与AM
</a>
</li>
<li class="chapter " data-level="1.4.4" data-path="2.4.html">
<a href="2.4.html">
基础设施(2)
</a>
</li>
<li class="chapter " data-level="1.4.5" data-path="2.5.html">
<a href="2.5.html">
输入输出
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.5" data-path="PA3.html">
<a href="PA3.html">
PA3 - 穿越时空的旅程: 批处理系统
</a>
<ul class="articles">
<li class="chapter " data-level="1.5.1" data-path="3.1.html">
<a href="3.1.html">
最简单的操作系统
</a>
</li>
<li class="chapter " data-level="1.5.2" data-path="3.2.html">
<a href="3.2.html">
穿越时空的旅程
</a>
</li>
<li class="chapter " data-level="1.5.3" data-path="3.3.html">
<a href="3.3.html">
用户程序和系统调用
</a>
</li>
<li class="chapter " data-level="1.5.4" data-path="3.4.html">
<a href="3.4.html">
文件系统
</a>
</li>
<li class="chapter " data-level="1.5.5" data-path="3.5.html">
<a href="3.5.html">
精彩纷呈的应用程序
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.6" data-path="PA4.html">
<a href="PA4.html">
PA4 - 虚实交错的魔法: 分时多任务
</a>
<ul class="articles">
<li class="chapter " data-level="1.6.1" data-path="4.1.html">
<a href="4.1.html">
多道程序
</a>
</li>
<li class="chapter " data-level="1.6.2" data-path="4.2.html">
<a href="4.2.html">
虚实交错的魔法
</a>
</li>
<li class="chapter " data-level="1.6.3" data-path="4.3.html">
<a href="4.3.html">
超越容量的界限
</a>
</li>
<li class="chapter " data-level="1.6.4" data-path="4.4.html">
<a href="4.4.html">
来自外部的声音
</a>
</li>
<li class="chapter " data-level="1.6.5" data-path="4.5.html">
<a href="4.5.html">
编写不朽的传奇
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.7" data-path="blank.html">
<a href="blank.html">
杂项
</a>
<ul class="articles">
<li class="chapter " data-level="1.7.1" data-path="FAQ.html">
<a href="FAQ.html">
常见问题(FAQ)
</a>
</li>
<li class="chapter " data-level="1.7.2" data-path="why.html">
<a href="why.html">
为什么要学习计算机系统基础
</a>
</li>
<li class="chapter " data-level="1.7.3" data-path="linux.html">
<a href="linux.html">
Linux入门教程
</a>
</li>
<li class="chapter " data-level="1.7.4" data-path="man.html">
<a href="man.html">
man入门教程
</a>
</li>
<li class="chapter " data-level="1.7.5" data-path="git.html">
<a href="git.html">
git入门教程
</a>
</li>
<li class="chapter " data-level="1.7.6" data-path="nemu-isa-api.html">
<a href="nemu-isa-api.html">
NEMU ISA相关API说明文档
</a>
</li>
<li class="chapter " data-level="1.7.7" data-path="changelog.html">
<a href="changelog.html">
更新日志
</a>
</li>
<li class="chapter " data-level="1.7.8" data-path="i386-intro.html">
<a href="i386-intro.html">
i386手册指令集阅读指南
</a>
</li>
<li class="chapter " data-level="1.7.9" data-path="exec.html">
<a href="exec.html">
指令执行例子
</a>
</li>
</ul>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >Configuring vim</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h2 id="configuring-vim">Configuring vim</h2>
<pre><code>apt-get install vim
</code></pre><p><code>vim</code> is called <a href="https://code2048.com/post/war_3_editor/" target="_blank">编辑器之神</a>.
You will use <code>vim</code> for coding in all PAs and Labs, as well as editing other files.
If you prefer to <code>emacs</code>, you can download and install <code>emacs</code> from network mirrors.</p>
<h3 id="learning-vim">Learning vim</h3>
<p>You are going to be asked to modify a file using <code>vim</code>.
For most of you, this is the first time to use <code>vim</code>.
The operations in <code>vim</code> are quite different from other editors you have ever used.
To learn <code>vim</code>, you need a tutorial.
There are two ways to get tutorials:</p>
<ul>
<li>Issue the <code>vimtutor</code> command in terminal. This will launch a tutorial for <code>vim</code>.<font color="red">This way is recommended, since you can read the tutorial and practice at the same time.</font></li>
<li>Search the Internet with keyword "vim 教程", and you will find a lot of tutorials about <code>vim</code>.
Choose some of them to read, meanwhile you can practice with the a temporary file by<pre><code>vim test
</code></pre></li>
</ul>
<font color="red">PRACTICE IS VERY IMPORTANT. You can not learn anything by only reading the tutorials.</font>
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="为什么上课不讲gnulinux的使用"><i class="fa fa-bullhorn"></i> 为什么上课不讲GNU/Linux的使用?</h5></div><div class="panel-body"><p>你可能会想: 这是我第一次接触GNU/Linux, 为什么上课不讲讲怎么用?</p><p>因为说明书不是用来讲的, 是用来一边看一边操作的;
你也不能光靠道听途说来掌握这些工具, 而是要自己去动手尝试.
你在大学课堂上应该学习到的是那些一脉相承的知识,
然后去思考这些知识背后的原则和思想, 将来有能力将这些原则和思想应用到新的领域.</p><p>我们设计这些实验内容, 是为了让你明白, 你有能力自己去看教程学习新的工具;
以及, 以后接触新事物的时候, 你不应该等着别人来给你讲,
而应该自己主动去找教程来学习如何使用.</p></div></div>
<!-- -->
<div class="panel panel-info"><div class="panel-heading"><h5 class="panel-title" id="some-games-operated-with-vim"><i class="fa fa-comment-o"></i> Some games operated with vim</h5></div><div class="panel-body"><p>Here are some games to help you master some basic operations in <code>vim</code>. Have fun!</p><ul>
<li><a href="http://vim-adventures.com" target="_blank">Vim Adventures</a></li>
<li><a href="http://www.vimsnake.com" target="_blank">Vim Snake</a></li>
<li><a href="http://www.openvim.com/tutorial.html" target="_blank">Open Vim Tutorials</a></li>
<li><a href="http://www.vimgenius.com" target="_blank">Vim Genius</a></li>
</ul></div></div>
<!-- -->
<div class="panel panel-info"><div class="panel-heading"><h5 class="panel-title" id="the-power-of-vim"><i class="fa fa-comment-o"></i> The power of vim</h5></div><div class="panel-body"><p>You may never consider what can be done in such a "BAD" editor. Let's see two examples.</p><p>The first example is to generate the following file:</p><pre><code>1
2
3
.....
98
99
100
</code></pre><p>This file contains 100 lines, and each line contains a number.
What will you do? In <code>vim</code>, this is a piece of cake.
First change <code>vim</code> into normal state (when <code>vim</code> is just opened, it is in normal state),
then press the following keys sequentially:</p><pre><code>i1<ESC>q1yyp<C-a>q98@1
</code></pre><p>where <code><ESC></code> means the ESC key, and <code><C-a></code> means "Ctrl + a" here.
You only press no more than 15 keys to generate this file.
Is it amazing? What about a file with 1000 lines? What you do is just to press one more key:</p><pre><code>i1<ESC>q1yyp<C-a>q998@1
</code></pre><p>The magic behind this example is recording and replaying.
You initial the file with the first line.
Then record the generation of the second.
After that, you replay the generation for 998 times to obtain the file.</p><p>The second example is to modify a file. Suppose you have such a file:</p><pre><code>aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccccccddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeeefffffffffffffffffffffffff
ggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhh
iiiiiiiiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjjjjjjjj
</code></pre><p>You want to modify it into:</p><pre><code>bbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaa
dddddddddddddddddddddddddccccccccccccccccccccccccc
fffffffffffffffffffffffffeeeeeeeeeeeeeeeeeeeeeeeee
hhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggg
jjjjjjjjjjjjjjjjjjjjjjjjjiiiiiiiiiiiiiiiiiiiiiiiii
</code></pre><p>What will you do? In <code>vim</code>, this is a piece of cake, too.
First locate the cursor to first "a" in the first line.
And change <code>vim</code> into normal state, then press the following keys sequentially:</p><pre><code><C-v>24l4jd$p
</code></pre><p>where <code><C-v></code> means "Ctrl + v" here.
What about a file with 100 such lines? What you do is just to press one more key:</p><pre><code><C-v>24l99jd$p
</code></pre><p>Although these two examples are artificial, they display the powerful functionality of <code>vim</code>,
comparing with other editors you have used.</p></div></div>
<h3 id="enabling-syntax-highlight">Enabling syntax highlight</h3>
<p><code>vim</code> provides more improvements comparing with <code>vi</code>.
But these improvements are disabled by default.
Therefore, you should enable them first.</p>
<p>We take syntax highlight as an example to illustrate how to enable the features of <code>vim</code>.
To do this, you should modify the <code>vim</code> configuration file.
The file is called <code>.vimrc</code>, and it is located under <code>/etc/vim</code> directory.
We first make a copy of it to the home directory by <code>cp</code> command:</p>
<pre><code>cp /etc/vim/vimrc ~/.vimrc
</code></pre><p>And switch to the home directory if you are not under it yet:</p>
<pre><code>cd ~
</code></pre><p>If you use <code>ls</code> to list files, you will not see the <code>.vimrc</code> you just copied.
This is because a file whose name starts with a <code>.</code> is a hidden file in GNU/Linux.
To show hidden files, use <code>ls</code> with <code>-a</code> option:</p>
<pre><code>ls -a
</code></pre><p>Then open <code>.vimrc</code> using <code>vim</code>:</p>
<pre><code>vim .vimrc
</code></pre><p>After you learn some basic operations in <code>vim</code> (such as moving, inserting text, deleting text),
you can try to modify the <code>.vimrc</code> file as following:</p>
<pre><code class="lang-diff"><span class="hljs-comment">--- before modification</span>
<span class="hljs-comment">+++ after modification</span>
<span class="hljs-meta">@@ -17,3 +17,3 @@</span>
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
<span class="hljs-deletion">-"syntax on</span>
<span class="hljs-addition">+syntax on</span>
</code></pre>
<p>We present the modification with <a href="http://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html" target="_blank">GNU diff format</a>.
If you do not understand the diff format, please search the Internet for more information.</p>
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="为什么要stfw"><i class="fa fa-bullhorn"></i> 为什么要STFW?</h5></div><div class="panel-body"><p>你或许会想, 我问别人是为了节省我的时间.</p><p>但现在是互联网时代了, 在网上你能得到各种信息:
比如diff格式这种标准信息, 网上是100%能搜到的;
就包括你遇到的问题, 很大概率也是别人在网上求助过的.
如果对于一个你本来只需要在搜索引擎上输入几个关键字就能找到解决方案的问题,
你都没有付出如此微小的努力, 而是首先想着找人来帮你解决, 占用别人宝贵的时间,
你将是这个时代的<font color="red">失败者</font>.</p><p>于是有了STFW (Search The F**king Web) 的说法, 它的意思是,
在向别人求助之前自己先尝试通过正确的方式使用搜索引擎独立寻找解决方案.</p><p>正确的STFW方式能够增加找到解决方案的概率, 包括</p><ul>
<li>使用<a href="www.google.com">Google搜索引擎</a>搜索一般性问题</li>
<li>使用<a href="http://en.wikipedia.org" target="_blank">英文维基百科</a>查阅概念</li>
<li>使用<a href="http://stackoverflow.com" target="_blank">stack overflow问答网站</a>搜索程序设计相关问题</li>
</ul><p>如果你没有使用上述方式来STFW, 请不要抱怨找不到解决方案而开始向别人求助,
你应该想, "噢我刚才用的是百度, 接下来我应该试试Google".
关于使用Google, 在学校可以尝试设置IPv6, 或者设置"科学上网", 具体设置方式请STFW.</p></div></div>
<!-- -->
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="为什么不要用百度"><i class="fa fa-bullhorn"></i> 为什么不要用百度?</h5></div><div class="panel-body"><p>相信大家都用过百度来搜索一些非技术问题, 而且一般很容易找到答案.
但随着问题技术含量的提高, 百度的搜索结果会变得越来越不靠谱.
坚持使用百度搜索技术问题, 你将很有可能会碰到以下情况之一:</p><ul>
<li>搜不到相关结果, 你感到挫败</li>
<li>搜到看似相关的结果, 但无法解决问题, 你在感到挫败之余, 也发现自己浪费了不少时间</li>
<li>你搜到了解决问题的方案, 但没有发现原因分析, 结果你不知道这个问题背后的细节</li>
</ul><p>你可能会觉得"可以解决问题就行, 不需要了解问题背后的细节".
但对于一些问题(例如编程问题), 你了解这些细节就相当于学到了新的知识,
所以你应该去了解这些细节, 让自己懂得更多.</p><p>如果谷歌能以更高的概率提供可以解决问题的方案, 并且带有原因分析,
你应该没有理由使用百度来搜索技术问题.
如果你仍然坚持使用百度, 原因就只有一个: 你不想主动去成长.</p></div></div>
<p>After you are done, you should save your modification.
Exit <code>vim</code> and open the <code>.vimrc</code> file again, you should see the syntax highlight feature is enabled.</p>
<div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="为什么要这么麻烦"><i class="fa fa-bullhorn"></i> 为什么要这么麻烦?</h5></div><div class="panel-body"><p>搞了半天, 你发现其实也就是改动一个字符而已, 为什么不直接说清楚呢?</p><p>这是为了"入乡随俗": 我们希望你了解怎么用计算机思维精简准确地表达我们想做的事情.
diff格式是一种描述文件改动的常用方式.
实际上, 计算机的世界里面有很多约定俗成的"规矩",
当你慢慢去接触去了解这些规矩的时候, 你就会在不知不觉中明白计算机世界是怎么运转的.</p></div></div>
<h3 id="enabling-more-vim-features">Enabling more vim features</h3>
<p>Modify the <code>.vimrc</code> file mentioned above as the following:</p>
<pre><code class="lang-diff"><span class="hljs-comment">--- before modification</span>
<span class="hljs-comment">+++ after modification</span>
<span class="hljs-meta">@@ -21,3 +21,3 @@</span>
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
<span class="hljs-deletion">-"set background=dark</span>
<span class="hljs-addition">+set background=dark</span>
<span class="hljs-meta">@@ -31,5 +31,5 @@</span>
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
<span class="hljs-deletion">-"filetype plugin indent on</span>
<span class="hljs-addition">+filetype plugin indent on</span>
<span class="hljs-meta">@@ -37,10 +37,10 @@</span>
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
<span class="hljs-deletion">-"set showmatch " Show matching brackets.</span>
<span class="hljs-deletion">-"set ignorecase " Do case insensitive matching</span>
<span class="hljs-deletion">-"set smartcase " Do smart case matching</span>
<span class="hljs-deletion">-"set incsearch " Incremental search</span>
<span class="hljs-addition">+set showmatch " Show matching brackets.</span>
<span class="hljs-addition">+set ignorecase " Do case insensitive matching</span>
<span class="hljs-addition">+set smartcase " Do smart case matching</span>
<span class="hljs-addition">+set incsearch " Incremental search</span>
"set autowrite " Automatically save before commands like :next and :make
<span class="hljs-deletion">-"set hidden " Hide buffers when they are abandoned</span>
<span class="hljs-addition">+set hidden " Hide buffers when they are abandoned</span>
"set mouse=a " Enable mouse usage (all modes)
</code></pre>
<p>You can append the following content at the end of the <code>.vimrc</code> file to enable more features.
Note that contents after a double quotation mark <code>"</code> are comments, and you do not need to include them.
Of course, you can inspect every features to determine to enable or not.</p>
<pre><code>setlocal noswapfile " 不要生成swap文件
set bufhidden=hide " 当buffer被丢弃的时候隐藏它
colorscheme evening " 设定配色方案
set number " 显示行号
set cursorline " 突出显示当前行
set ruler " 打开状态栏标尺
set shiftwidth=2 " 设定 << 和 >> 命令移动时的宽度为 2
set softtabstop=2 " 使得按退格键时可以一次删掉 2 个空格
set tabstop=2 " 设定 tab 长度为 2
set nobackup " 覆盖文件时不备份
set autochdir " 自动切换当前目录为当前文件所在的目录
set backupcopy=yes " 设置备份时的行为为覆盖
set hlsearch " 搜索时高亮显示被找到的文本
set noerrorbells " 关闭错误信息响铃
set novisualbell " 关闭使用可视响铃代替呼叫
set t_vb= " 置空错误铃声的终端代码
set matchtime=2 " 短暂跳转到匹配括号的时间
set magic " 设置魔术
set smartindent " 开启新行时使用智能自动缩进
set backspace=indent,eol,start " 不设定在插入状态无法用退格键和 Delete 键删除回车符
set cmdheight=1 " 设定命令行的行数为 1
set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ Ln\ %l,\ Col\ %c/%L%) " 设置在状态行显示的信息
set foldenable " 开始折叠
set foldmethod=syntax " 设置语法折叠
set foldcolumn=0 " 设置折叠区域的宽度
setlocal foldlevel=1 " 设置折叠层数为 1
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> " 用空格键来开关折叠
</code></pre><div class="panel panel-danger"><div class="panel-heading"><h5 class="panel-title" id="提高开发效率的编辑器"><i class="fa fa-bullhorn"></i> 提高开发效率的编辑器</h5></div><div class="panel-body"><p>程序设计课上你学会了使用Visual Studio, 然后你可能会认为, 程序员就是这样写代码的了.
其实并不是, 程序员会追求那些提高效率的方法.
不是GUI不好, 而是你只是用记事本的操作方式来写代码.
所以你需要改变, 去尝试一些可以帮助你提高开发效率的工具.</p><p>在GNU/Linux中, 与记事本的操作方式相比, 学会<code>vim</code>的基本操作就已经可以大大提高开发效率.
还有各种插件来增强<code>vim</code>的功能, 比如可以在代码中变量跳转的<code>ctags</code>等等.
你可以花点时间去配置一下<code>vim</code>, 具体配置方式请STFW.
总之, "编辑器之神"可不是浪得虚名的.</p></div></div>
<footer class="page-footer-ex"> <span class="page-footer-ex-copyright"> By <a href="https://sashimi-yzh.github.io/" target="_blank">Zihao Yu</a>, 采用<a href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank">知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议</a>发布 </span>            <span class="page-footer-ex-footer-update"> 此页面修订于: 2023-03-08 15:21:05 </span> </footer>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="0.3.html" class="navigation navigation-prev " aria-label="Previous page: Installing Tools">
<i class="fa fa-angle-left"></i>
</a>
<a href="0.5.html" class="navigation navigation-next " aria-label="Next page: More Exploration">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Configuring vim","level":"1.2.4","depth":2,"next":{"title":"More Exploration","level":"1.2.5","depth":2,"path":"0.5.md","ref":"0.5.md","articles":[]},"previous":{"title":"Installing Tools","level":"1.2.3","depth":2,"path":"0.3.md","ref":"0.3.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"3.x.x","theme":"default","variables":{},"plugins":["theme-comscore","intopic-toc","localized-footer","page-footer-ex","callouts"],"pluginsConfig":{"callouts":{"option":{"alert":"info","picto":"fa-edit"},"flag":{"alert":"success","picto":"fa-flag"},"question":{"alert":"info","picto":"fa-question-circle"},"info":{"alert":"info","picto":"fa-info-circle"},"todo":{"alert":"warning","picto":"fa-edit"},"caution":{"alert":"danger","picto":"fa-bullhorn"},"danger":{"alert":"danger","picto":"fa-exclamation"},"showTypeInHeader":false},"intopic-toc":{"isCollapsed":false,"isScrollspyActive":true,"label":"导航","maxDepth":6,"mode":"nested","selector":".markdown-section h2, .markdown-section h3, .markdown-section h4","visible":true},"page-footer-ex":{"copyright":"By [Zihao Yu](https://sashimi-yzh.github.io/), 采用[知识共享 署名-非商业性使用-相同方式共享 3.0 中国大陆 许可协议](http://creativecommons.org/licenses/by-nc-sa/3.0/cn/)发布","markdown":true,"update_format":"YYYY-MM-DD HH:mm:ss","update_label":"此页面修订于: "},"search":{},"localized-footer":{"filename":"FOOTER.md","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles.css","pdf":"styles.css"}},"file":{"path":"0.4.md","mtime":"2023-03-08T07:21:05.282Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2025-01-03T02:26:44.310Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>